Greasy Fork is available in English.

讨论 » 开发

script stop working when minimized or when change tab

§
发表于:2022-03-18

im using this script on chrome and when i change to excel it stops i use it to autoclick on button
```
// ==UserScript==
// @name netsuite
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// ==/UserScript==

setTimeout(() => {
alert("Auto-clicking is now enabled");
let run = false;

window.addEventListener("keydown", (e) => {
if (e.key === "Control") {
window.addEventListener("keyup", (e) => {
if (e.key === ".") {
if (run) {
run = false;

clearInterval(window.interval);
console.log("Auto-clicking is now disabled");
};
} else if (e.key === "Enter") {
if (!run) {
run = true;
let ids = prompt("Enter the IDs to omit: ").split(" ");

window.interval = setInterval(() => {
autoClick(ids);
}, 100);
};
};
});

};
});
}, 30000);


function autoClick(ids) {
let elements = document.getElementsByClassName("listinlinefocusedrowcellnoedit");
console.log("In autoClick");
for (let i = 0; i < elements.length; i++) {
for (const id in ids) {
if (!elements[i].innerText.includes(ids[id])) {
console.log("Match found");
document.getElementsByClassName("uir-remove bntBg")[0].firstElementChild.click();
};
};
};
};```

发表回复

登录以发表回复。