gpt4 book ai didi

javascript - Greasemonkey 注入(inject) Adfly 广告

转载 作者:行者123 更新时间:2023-12-02 20:09:42 26 4
gpt4 key购买 nike

有什么方法可以将其转换为 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 注入(inject)到页面中。 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com