我为网站创建了一个 Greasemonkey 脚本。该脚本所做的是在页面末尾添加一个 div。
document.body.insertBefore(myDiv, document.body.firstChild);
但是现在该网站为 google-ads 添加了一个 iframe,结果我的 div 也出现在 iframe 中,这不是我想要的。
如何停止影响 iframe 的脚本?
最佳答案
我将它放在脚本的顶部以避免在框架或 iframe 上运行:
if (window.top != window.self) //don't run on frames or iframes
return;
关于javascript - 如何在 Greasemonkey 或 Tampermonkey 中排除 iframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1535404/