Greasy Fork

Greasy Fork is available in English.

DuckDuckGo on Yandex

Replaces Bing links with DuckDuckGo on Yandex search results page and updates the link text

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         DuckDuckGo on Yandex
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Replaces Bing links with DuckDuckGo on Yandex search results page and updates the link text
// @author       nnside
// @match        https://yandex.ru/search/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to replace links
    function replaceBingLinks() {
        // Get all link elements on the page
        const links = document.querySelectorAll('a');

        // Iterate through all links
        links.forEach(link => {
            // Check if the link contains the Bing address
            if (link.href.includes("bing.com")) {
                // Replace the link with DuckDuckGo
                const searchText = new URLSearchParams(window.location.search).get('text');
                link.href = `https://duckduckgo.com/?q=${encodeURIComponent(searchText)}`;
                link.target = '_blank';  // Open in a new tab

                // Change the link text to "DuckDuckGo"
                link.textContent = link.textContent.replace("Bing", "DuckDuckGo");
            }
        });
    }

    // Create a MutationObserver to watch for changes in the document
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(() => {
            replaceBingLinks(); // Call the function each time the DOM changes
        });
    });

    // Start observing the body for child additions
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Initial call to replace links when the script runs
    replaceBingLinks();

})();