Firefox 脚本化和脚本启动的多次迭代
脚本被启动了5次,我不知道为什么或者如何停止其他实例。其他实例似乎永远无法找到任何具有类名(Firefox 脚本化和脚本启动的多次迭代,firefox,javascript,Firefox,Javascript,脚本被启动了5次,我不知道为什么或者如何停止其他实例。其他实例似乎永远无法找到任何具有类名(gb\u l gb\u n)的元素,并向我报告名称。长度为0。它还真的很奇怪,因为它只会记录name.length的部分,而不会记录任何其他console.log,除非它确实获得了变量名的值 下面是一个完整的脚本,其中包含了试图找出如何阻止此脚本每10秒运行一次(最初设置为1秒)的全部步骤: 这是在黑暗中拍摄的,但您的脚本也可能在mail.google.com上的任何iFrame上运行。要停止脚本在iFr
gb\u l gb\u n
)的元素,并向我报告名称。长度为0
。它还真的很奇怪,因为它只会记录name.length
的部分,而不会记录任何其他console.log
,除非它确实获得了变量名的值
下面是一个完整的脚本,其中包含了试图找出如何阻止此脚本每10秒运行一次(最初设置为1秒)的全部步骤:
这是在黑暗中拍摄的,但您的脚本也可能在mail.google.com上的任何iFrame上运行。要停止脚本在iFrame上运行,有两个选项
在脚本的元数据块中,可以将@noframes设置为true
// ==UserScript==
// @id rtskincruff
// @name Right Gmail
// @version 1.0
// @namespace OK
// @author Exaskryz
// @description
// @include https://mail.google.com/*
// @run-at document-idle
// ==/UserScript==
var colored = setInterval(function () {coloring()}, 10000);
function coloring() {
console.log("ping");
var name = document.getElementsByClassName("gb_l gb_n");
console.log("got name");
console.log(name.length);
if (name[0].innerHTML = "+Exaskryz") {
name[0].style.color = "#FF0000";
name[0].style.fontSize = "xx-large";
name[0].innerHTML = "WRONG ACCOUNT TO SEND EMAIL FROM";
//var backg = document.getElementsByClassName("AO");
//backg[0].style.backgroundColor = "#FF0000";
} else if (name[0].innerHTML = "WRONG ACCOUNT TO SEND EMAIL FROM") {
clearInterval(colored);
alert("pun");
}
console.log("passed first if");
if (name.length>0) {
if (name[0].innerHTML = "+Exaskryz") {
name[0].style.color = "#FF0000";
name[0].style.fontSize = "xx-large";
name[0].innerHTML = "WRONG ACCOUNT TO SEND EMAIL FROM";
//var backg = document.getElementsByClassName("AO");
//backg[0].style.backgroundColor = "#FF0000";
alert("bun");
clearInterval(colored);
alert("done");
}
}
console.log("passed second if");
var nong = document.getElementsByClassName("gb_K gb_ka gb_n gb_ga");
console.log("got nong");
alert(nong.length);
if (nong[0].innerHTML = "CorrectAccount@gmail.com") {
alert("hun");
clearInterval(colored);
alert("done");
}
}
或者,您可以在脚本的开头检查脚本的窗口是否实际上是“最顶部”窗口
// @noframes true
// @noframes true
if (window != window.top) { return; }