繁体   English   中英

如何执行页面上的功能?

[英]How to execute function on page?

在下文中,我将使用此页面来测试http://nitroflare.com/view/A71F0994E20F2E0/security-privacy.jpg

下面的脚本单击“慢速下载”,然后删除单击后显示的弹出广告。

我要单击第二个单击函数,而不是单击“免费下载”,这将首先弹出一个窗口。

function () {
    $(this).hide();
    $("#CountDownTimerContainer").show();
    startFreeDownload();
}

我的脚本执行$("#CountDownTimerContainer").show()但是由于某种原因它没有执行startFreeDownload()

如何调用页面上的startFreeDownload()

// ==UserScript==
// @name        NitroFlare
// @namespace   https://nitroflare.com/
// @description https://nitroflare.com/
// @include     https://nitroflare.com/*
// @version     1
// @grant       none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// ==/UserScript==

function SkipId(objId){
  var oId = document.getElementById(objId);
  oId.click();
}

window.onload = function(){
  SkipId('slow-download');
};

waitForKeyElements("div.superbox-wrapper", removeSuperbox);

function removeSuperbox() {
  document.getElementById('superbox-wrapper').hide();
}

$("#CountDownTimerContainer").show();
startFreeDownload();

document.getElementById返回一个DOM节点,该节点没有hide()方法。

手动使用jQuery: $('#superbox-wrapper').hide()或使用waitForKeyElements,如其示例所示:

function removeSuperbox(jNode) {
  jNode.hide();
}

另外,由于您要在页面中注入自己的jQuery并使用@grant none ,因此如果站点具有自己的jQuery,则可能需要使用jQuery.noConflict()。

(function (){
    $("#CountDownTimerContainer").show();
    console.log(0);
    startFreeDownload();
})();

function startFreeDownload(){
  console.log(1);
}

试试这个,它应该为您工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM