简体   繁体   English

如何使用Violentmonkey脚本跳过此倒计时

[英]How to skip this countdown using Violentmonkey script

Is there a way to make a greasemonkey script to skip this countdown? 有没有办法让一个greasemonkey脚本跳过这个倒计时? I've already tried to make a script by myself but I'm very newbie at javascript so I couldn't figure out a way to that. 我已经尝试自己创建一个脚本,但我是javascript的新手,所以我无法想出办法。

Here's the code of the countdown (it is an inline script, and it is the only inline script in that page). 这是倒计时的代码(它是一个内联脚本,它是该页面中唯一的内联脚本)。

MY CODE 我的代码

// ==UserScript==
// @name Site Countdown Skip
// @autor SecretX
// @namespace namespace_secretx
// @description Skip the silly countdown.
// @version 2019.06.23
// @match http://example.com/download/?*
// @match https:/example.com/download/?*
// @grant none
// ==/UserScript==

var changed = 0;

window.addEventListener('beforescriptexecute', function(e) {

    if(e.target===document.getElementsByTagName("script")[0]){
        e.stopPropagation();
        e.preventDefault();
    }
    window.removeEventListener(e.type, arguments.callee, true);
}, true);

PAGE CODE PAGE CODE

<div id="pleasewait">Please wait <span id="contador">15</span> seconds</div>
<iframe class="clearfix" src="https://a.site.com.br/download/php_code.php" id="iframe" style="border: 0;width:100%;height:100%;" __idm_frm__="12884901909"></iframe>
<script type="text/javascript">
  var seconds;
  var temp;

  function countdown() {
    seconds = document.getElementById('countdown1').innerHTML;
    seconds = parseInt(seconds, 10);

    if (seconds == 1) {
      temp = document.getElementById('pleasewait');
      temp.innerHTML = '<a href="magnet:?xt=urn:btih:00et8wt78wga5tre874fe8afw8w&amp;dn=Video_File_999_FHD.mkv&amp;xl=687980321&amp;tr=udp://tracker.tracker.org:1337/announce" id="continuar"><i id="cola"></i></a>';
      return;
    }

    seconds--;
    temp = document.getElementById('countdown1');
    temp.innerHTML = seconds;
    timeoutMyOswego = setTimeout(countdown, 1000);
  } 

  countdown();
</script>

Based on the code you posted, if you want to skip the count down as much as you can without editing the HTML or JS in your second block of code, then you can just add this line of JS to your document: 根据您发布的代码,如果您想在不编辑第二个代码块中的HTML或JS的情况下尽可能地跳过倒计时,那么您只需将这行JS添加到您的文档中:

document.getElementById('countdown1').innerHTML = 1;

This will set the elements innerHtml to 1. In the JS function countdown() , there is an if statement that is checking if the innerHtml of the "countdown1" element is 1, and if so then it updates the "temp" elements contents. 这会将元素innerHtml设置为1.在JS函数countdown() ,有一个if语句检查“countdown1”元素的innerHtml是否为1,如果是,则更新“temp”元素内容。

Here is an example: 这是一个例子:

 <div id="pleasewait">Please wait <span id="countdown1">15</span> seconds</div> <iframe class="clearfix" src="https://a.site.com.br/download/php_code.php" id="iframe" style="border: 0;width:100%;height:100%;" __idm_frm__="12884901909"></iframe> <script> document.getElementById('countdown1').innerHTML = 1 </script> <script type="text/javascript"> var seconds; var temp; function countdown() { seconds = document.getElementById('countdown1').innerHTML; seconds = parseInt(seconds, 10); if (seconds == 1) { temp = document.getElementById('pleasewait'); temp.innerHTML = 'LOAD THIS'; return; } seconds--; temp = document.getElementById('countdown1'); temp.innerHTML = seconds; timeoutMyOswego = setTimeout(countdown, 1000); } countdown(); </script> 

I wrote LOAD THIS instead of what was there originally just for the example, all you really need to do is to put this line: 我写了LOAD THIS而不是最初只是为了这个例子,你真正需要做的就是把这行:

<script>
    document.getElementById('countdown1').innerHTML = 1
</script>

After this element: 在这个元素之后:

<div id="pleasewait">Please wait <span id="countdown1">15</span> seconds</div>

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

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