Greasy Fork

Greasy Fork is available in English.

Replace Bing with DuckDuckGo on Yandex

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

目前为 2025-04-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         Replace Bing with DuckDuckGo on Yandex
// @namespace    http://tampermonkey.net/
// @version      0.3
// @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");
            }
        });
    }

    // Run the function after the page loads
    window.onload = replaceBingLinks;

})();