有什么办法可以将其转换为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链接加载到浏览器中的脚本。
请帮忙!
谢谢 :)
最佳答案
您需要将JS注入页面。 Avoid unsafeWindow
if you can。
这是该脚本的完整Greasemonkey翻译:
// ==UserScript==
// @name _adFly why?
// @include http://YOUR_SITE/YOUR_PATH/*
// ==/UserScript==
function myCode () {
//--- Set global variables for adFly.
window.adfly_id = 517450;
window.adfly_advert = 'banner';
window.frequency_cap = 5;
window.frequency_delay = 5;
window.init_delay = 3;
}
addJS_Node (null, null, myCode);
addJS_Node (null, "http://adf.ly/js/entry.js");
function addJS_Node (text, s_URL, funcToRun) {
var D = document;
var scriptNode = D.createElement ('script');
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
var targ = document.getElementsByTagName('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
关于javascript - Greasemonkey注入(inject)Adfly广告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7081776/