Greasemonkey 注入 Adfly 广告
有什么办法可以将其转换为 Greasemonkey 代码吗?
<script>
var adfly_id = 517450;
var adfly_advert = 'banner';
var frequency_cap = 5;
var frequency_delay = 5;
var init_delay = 3;
</script>
<script src="http://adf.ly/js/entry.js"></script>
这是 adf.ly 的网站入口脚本,添加到网站后会显示 adf.ly 广告。
我想制作一个脚本,在冲浪时在浏览器中加载 adf.ly 链接。
请帮忙! 谢谢 :)
Is there any way to convert this into Greasemonkey code?
<script>
var adfly_id = 517450;
var adfly_advert = 'banner';
var frequency_cap = 5;
var frequency_delay = 5;
var init_delay = 3;
</script>
<script src="http://adf.ly/js/entry.js"></script>
It's a website entry script for adf.ly which when added to a website brings up adf.ly ads.
I want to make a script that will load adf.ly links in the browser while surfing.
Please help!
Thank You :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 JS 注入到页面中。 尽可能避免
unsafeWindow
。以下是该脚本的完整 Greasemonkey 翻译:
You'll need to inject the JS into the page. Avoid
unsafeWindow
if you can.Here's a complete Greasemonkey translation of that script:
是的,理论上。你只需要将这些写到头部即可。如果您在页面方向加载它们,它们将在greasemonkey范围之外进行评估。您甚至可以在创建脚本标记后执行
document.body.appendChild
。因此,对于另一个,执行
unsafeWindow.varname
赋值可能会更容易,例如虽然您不想在脚本中使用这些值,因为可以通过以下方式更改这些值:网站本身。使用它们可以让网站更好地控制用户浏览器,并让他们执行原本无法执行的操作(例如,通过 XSS ajax 访问其他网站的信息)。只写入 unsafeWindow 中的值,不要读取其中的值。
Yes, in theory. You'd just need to write these to the head. They will evaluate outside of the greasemonkey scope if you load them on the page direction. you can even just do a
document.body.appendChild
after creating script tags. So,For the other one, it'd probably just be easier to do an
unsafeWindow.varname
assignment likeThough you don't ever want to use these values in your script, as these can be changed by the website itself. Using them gives websites access to more control over a users browser and lets them do things that they would not otherwise be able to do (for example, accessing information from other websites via XSS ajax). Only write to values in unsafeWindow, don't read from them.