DuckDuckGo Images for Brave search

Inserts DuckDuckGo images tab into Brave search

目前為 2023-08-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         DuckDuckGo Images for Brave search
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Inserts DuckDuckGo images tab into Brave search
// @author       Nobody
// @match        https://search.brave.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=brave.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function insertDuckImagesMenu() {
    // Find the 2nd <li> element in <ul id="primary-tabs"> tree
    const tabImages = document.getElementById('primary-tabs').children[1];

    // Get the <a> element within the <li>
    const tabImagesLink = tabImages.querySelector('a');

    // Get the current href attribute value
    let href = tabImagesLink.getAttribute('href');

    // Extract the search query from the href
    const queryStart = href.indexOf('q=') + 2;
    const queryEnd = href.indexOf('&source=web');
    const searchQuery = href.substring(queryStart);



    // Generate the new URL
    const newURL = `https://duckduckgo.com/?q=${searchQuery}&iax=images&ia=images`;

    // Create a new <li> element
    const newLiElement = document.createElement('li');
    newLiElement.setAttribute('class', 'tab-item  svelte-1ho7sno');

    // Create a new <a> element
    const newLink = document.createElement('a');
    newLink.setAttribute('href', newURL);
    newLink.setAttribute('target', '_blank');
    newLink.setAttribute('class', 'svelte-1ho7sno');

    // Create the icon element
    const iconWrapper = document.createElement('span');
    iconWrapper.setAttribute('class', 'icon-wrapper');
    const iconSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
    iconSVG.setAttribute('class', 'icon');
    iconSVG.setAttribute('width', '17');
    iconSVG.setAttribute('height', '17');
    iconSVG.setAttribute('viewBox', '0 0 17 17');
    iconSVG.innerHTML = '<path fill-rule="evenodd" clip-rule="evenodd" d="M12.492 2.093h-8a2.6 2.6 0 00-2.6 2.6v8a2.6 2.6 0 002.6 2.6h8a2.6 2.6 0 002.6-2.6v-8a2.6 2.6 0 00-2.6-2.6zm-8-1.4a4 4 0 00-4 4v8a4 4 0 004 4h8a4 4 0 004-4v-8a4 4 0 00-4-4h-8zm5.46 7.048a.7.7 0 01.514.156l2.971 2.447a.7.7 0 01-.89 1.08L10.12 9.427l-2.172 2.676a.7.7 0 01-1.001.088l-1.142-.987L4.55 12.86a.7.7 0 01-1.116-.845L5.14 9.763a.7.7 0 011.016-.107l1.16 1.003 2.162-2.663a.7.7 0 01.473-.255zM4.34 5.291a.5.5 0 111 0 .5.5 0 01-1 0zm.5-1.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"></path>';

    // Append the icon element to the new <a> element
    iconWrapper.appendChild(iconSVG);
    newLink.appendChild(iconWrapper);

    // Create the text element
    const textSpan = document.createElement('span');
    textSpan.textContent = 'D Img';

    // Append the text element to the new <a> element
    newLink.appendChild(textSpan);

    // Append the new <a> element to the new <li> element
    newLiElement.appendChild(newLink);

    // Insert the new <li> element before the tabImages element
    tabImages.parentNode.insertBefore(newLiElement, tabImages);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址