Move Floating Bing Search Icon Right

Move Floating bing search icon right on the page

// ==UserScript==
// @name         Move Floating Bing Search Icon Right
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  Move Floating bing search icon right on the page
// @author       aspen138
// @match        *://www.bing.com/search?q=*
// @match        *://cn.bing.com/search?q=*
// @grant        none
// @license     MIT
// ==/UserScript==




(function() {
    'use strict';

    // Function to move the icon to the right
    const moveIconRight = () => {
        const iconContainer = document.querySelector('.b_ds5');
        if (iconContainer && window.getComputedStyle(iconContainer).display !== 'none') {
            // Icon is visible, move it to the right
            iconContainer.style.marginLeft = '360px'; //修改这里就行
        }
    };

    // Observe changes in the attribute values of the body element and its descendants
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.type === "attributes" && mutation.attributeName === "style") {
                moveIconRight();
            }
        });
    });

    // Start observing for changes in the page
    observer.observe(document.body, {
        attributes: true,
        subtree: true,
        attributeFilter: ['style'] // Only listen for style changes
    });

    // Initial check in case the icon is already visible on load (optional)
    moveIconRight();
})();