Google translate auto slide on mouseover
当前为
// ==UserScript==
// @name Google translate auto slide
// @namespace http://tampermonkey.net/
// @version 0.5
// @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 = null;
}
}
}
}
});
observer.observe(document.body, {childList: true});
})();