Google translate auto slide

Google translate auto slide on mouseover

目前为 2023-02-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         Google translate auto slide
// @namespace    http://tampermonkey.net/
// @version      0.55
// @description  Google translate auto slide on mouseover
// @author       aseg
// @match        https://*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let zcont = null;
	let observer = new MutationObserver(mutations => {
        for(let mutation of mutations) {
            // examine new nodes
            for(let node of mutation.addedNodes)
            {
                if(!(node instanceof HTMLElement))
                {
                    continue;
                }
                if(document.getElementById(":0.container"))
				{
                    zcont = document.getElementById(":0.container");
                }
            }
        }

        if(zcont)
        {
            zcont.style.width = "31px";
            zcont.style.marginLeft = "-10px";
            zcont.style.borderRadius = "8px";

            zcont.onmouseover = function()
            {
                zcont.style.width = "100%";
                zcont.style.marginLeft = "0px";
                zcont.style.borderRadius = "0px";

                document.onmousemove = function(evt)
                {
                    let evtDoc, doc, body;

                    evt = evt || window.evt;

                    if (evt.pageY == null && evt.clientY != null)
                    {
                        evtDoc = (evt.target && evt.target.ownerDocument) || document;
                        doc = evtDoc.documentElement;
                        body = evtDoc.body;

                        evt.pageY = evt.clientY +
                                    (doc && doc.scrollTop || body && body.scrollTop || 0) -
                                    (doc && doc.clientTop || body && body.clientTop || 0 );
                    }

                    if(evt.pageY > 65)
                    {
                        zcont.style.width = "31px";
                        zcont.style.marginLeft = "-10px";
                        zcont.style.borderRadius = "8px";

                        document.onmousemove = function(){};
                    }
                }
            }
        }
    });

    observer.observe(document.body, {childList: true});
})();

QingJ © 2025

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