如何在页面上执行功能?

How to execute function on page?

下面我用这个页面进行测试http://nitroflare.com/view/A71F0994E20F2E0/security-privacy.jpg

下面的脚本点击慢速下载并删除点击后出现的弹出式广告。

我不想点击免费下载,它首先会弹出 window,我想调用它的第二次点击功能,即

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();
(function (){
    $("#CountDownTimerContainer").show();
    console.log(0);
    startFreeDownload();
})();

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

试试这个它应该适合你。

document.getElementById returns 一个 DOM 节点,它没有 hide() 方法。

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

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

此外,由于您要将自己的 jQuery 注入页面并使用 @grant none,如果网站有自己的 [=23],您可能需要使用 jQuery.noConflict() =].