简体   繁体   English

如何在另一个站点上修改变量?

[英]How can I modify a variable on another site?

My son is doing times tables practice on this page, a timed test in which he gets 10 seconds for each sum. 我儿子正在此页面上进行时间表练习,这是一个定时测试,每次累加他可获得10秒。

https://www.timestables.com/speed-test/ - this is not my site or code, I have no direct control over the source code. https://www.timestables.com/speed-test/-这不是我的网站或代码,我无法直接控制源代码。

I want to give him a little more time per sum but I cannot find a way to modify the relevant code and make it work with 20 seconds instead of 10. 我想给他每笔款项更多的时间,但是我找不到一种方法来修改相关的代码并使它的工作时间从20秒改为10秒。

It looks to me like the relevant variable is maxTime (milliseconds) in this function, but nothing I do using the Chrome Developer Tools will modify this in a live running page to give 20 seconds instead of 10. 在我看来,此函数中的相关变量为maxTime(毫秒),但我使用Chrome开发者工具所做的任何操作都不会在实时运行的页面中对此进行修改,以使其从20秒改为20秒。

function startSom(){


    vraagnr = vraagnr + 1;
    if(vraagnr <= totaalSommen)
    {
        bezig = true;
        $('#pbar_innerdiv').stop();
        $('#pbar_innerdiv').css("width","100%");
        $('#pbar_innerdiv').css("backgroundColor","#33BF00");
        $('#pbar_innerdiv').css("borderColor","#33BF00");
        if(mobiel){
        $("#antwVak").html("");
        }
        else{
            $("#antwoordI").val("");
            $("#antwoordI").focus();    
        }
        $('#pbar_innerdiv').stop();

        start = new Date();
        maxTime = 10000;
        timeoutVal = Math.floor(maxTime/100);
          var somT = sommen[vraagnr-1].split(",");
                $('#somVak').html(somT[1]+"×"+somT[0]+"=");
                $('#voortgangVak').html("Question "+vraagnr+" / "+totaalSommen+"<br />"+ punten + " points");

        animateUpdate();
        started = false;
    }
    else
    {
        showEindScherm();

    }
}

Can anyone suggest what to do please? 有人可以建议做什么吗?

You can copy the entire method, pase it into chrome devtools and change 您可以复制整个方法,将其放入chrome devtools中并进行更改

 function startSom() { 

to

window.startSom = function() {

And obviously change your time from 10000 to 20000. This changes the amount of time it allows you to answer, but not the moving progress bar which will still only take 10 seconds. 显然,您将时间从10000更改为20000。这将更改允许您回答的时间,但不会更改移动进度条,该进度条仍然只需要10秒。

Please paste this: 请粘贴:

window.startSom = function(){


    vraagnr = vraagnr + 1;
    if(vraagnr <= totaalSommen)
    {
        bezig = true;
        $('#pbar_innerdiv').stop();
        $('#pbar_innerdiv').css("width","100%");
        $('#pbar_innerdiv').css("backgroundColor","#33BF00");
        $('#pbar_innerdiv').css("borderColor","#33BF00");
        if(mobiel){
        $("#antwVak").html("");
        }
        else{
            $("#antwoordI").val("");
            $("#antwoordI").focus();    
        }
        $('#pbar_innerdiv').stop();

        start = new Date();
        maxTime = 20000;
        timeoutVal = Math.floor(maxTime/100);
          var somT = sommen[vraagnr-1].split(",");
                $('#somVak').html(somT[1]+"×"+somT[0]+"=");
                $('#voortgangVak').html("Question "+vraagnr+" / "+totaalSommen+"<br />"+ punten + " points");

        animateUpdate();
        started = false;
    }
    else
    {
        showEindScherm();

    }
}

Here: 这里: 在此处输入图片说明

And if you want to make the progress bar following the new max Time, also paste this: 而且,如果您想使进度条遵循新的最大时间,请粘贴以下内容:

window.animateUpdate = function() {
    if(bezig)
    {
    var now = new Date();

    var timeDiff = now.getTime() - start.getTime();
    if(!started){
        $('#pbar_innerdiv').css("width", (100) + "%");
        $('#pbar_innerdiv').animate({width: 0 + "%"},20000);

        started = true;
    }
    perc = Math.round((timeDiff/maxTime)*100);


        console.log(perc);

        if(perc == 33)
        {                           
            $('#pbar_innerdiv').css("backgroundColor", "#FF9500");
            $('#pbar_innerdiv').css("borderColor", "#FF9500");
        }
        if(perc== 66)
        {
            $('#pbar_innerdiv').css("backgroundColor", "#FF0000");
            $('#pbar_innerdiv').css("borderColor", "#FF0000");
        }
      if (perc <= 100) {
       //updateProgress(perc);
       setTimeout(animateUpdate, timeoutVal);

      } 
      else
      {
        bezig = false;
        showTeLaat();
        //alert("tijd is om");
      }
    }
}

There is a possibility to change files persistently in chrome devtools: Overrides . 可以在chrome devtools中永久更改文件: 覆盖

If the script is in a seperate file you can change the maxTime directly there or if it is in a file, which needs to be reloaded you can edit any other .js and add an eventlistener there to change the startSom method on page load. 如果脚本位于单独的文件中,则可以直接在其中更改maxTime;如果脚本位于文件中(需要重新加载),则可以编辑任何其他.js并在其中添加事件监听器,以在页面加载时更改startSom方法。

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

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