需要帮助调试lublessmonkey脚本

如何解决需要帮助调试lublessmonkey脚本

| 我在这里很新,与GM脚本一样。在Brock和其他成员的帮助下,我正在取得进步。 我目前遇到了调试Greasemonkey脚本的问题,但是由于某些原因,我无法掌握它。我的第一个问题是使用console.log调试firebug。 有时我会找到日志,大多数时候我找不到任何日志,猜想我在错误地使用它。然后尝试使用警报以查看变量值...相同的故事。 目前,我正试图在Brock Adams的大力帮助下,在Trada.net网站上处理一个脚本,以进行一些拍卖,我们已经完成了一半以上的工作,但是我仍然对JS脚本颇有兴趣。如果您接受我15年前就习惯了涡轮帕斯卡,那么安静的新体验。:) 好吧,目前这是我在脚本上得到的结果:
 // ==UserScript==
// @name           bid up to test3
// @include         http://www.trada.net/*
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// ==/UserScript==


//--- Create a cell for transmitting the date from page scope to GM scope.
$(\'body\'). prepend (\'<div id=\"LatestJSON_Data\"></div>\');

var J_DataCell          = $(\'#LatestJSON_Data\');


//--- Eavesdrop on the page\'s AJAX calls and paste the data into our special div.
unsafeWindow.$(\'body\').ajaxSuccess (
    function (event,requestData)
    {
        J_DataCell.text (requestData.responseText);
    }
);

// **bid function and var\'s
// **var interval            = 50;
// **var bidClickTimer       = setInterval (function() {BidClick (); },interval);
// **var numBidClicks        = 0;
// **var A1reset_go          = false;



// **function BidClick1 ()
// **{var //bidBtn1=document.getElementById(\"ctl00_mainContentPlaceholder_AirtimeAuctionItem1_btn_BidButton\");


//**    numBidClicks++;
//**    if (numBidClicks > 10)
//**    {   Alert(\"check10\");
//**        clearInterval (bidClickTimer);
//**        bidClickTimer   = \"\";
//**    }
//**    else
//**    {   Alert(\"check11\");
//**        bidBtn1.click (1);

//**    }
//**};

//**end bid function

//--- Listen for changes to the special div and parse the data.
J_DataCell.bind (\'DOMSubtreeModified\',ParseJSON_Data);

function ParseJSON_Data ()
{

//**my var
//**var auction_type ;A1_upto;A1_start;A1_current;A1_reset;
//**end my var

    //--- Get the latest data from the special cell and parse it.
    var myJson              = J_DataCell.text ();
    var jsonObj             = $.parseJSON (myJson);

    //--- The JSON should return a 2-D array,named \"d\".
    var BidDataArray        = jsonObj.d;

    //--- Loop over each row in the array.
    $.each (
        BidDataArray,function (rowIndex,rowValue) {

            //--- Print the 7th column.
            console.log (\'Row: \' + (parseInt (rowIndex) + 1) + \' Column: 7  Value: \' + rowValue[6]);

//** my part
//**   Alert(\"check1\");
//**  auction_type=parseInt (rowValue[4]);
//**   if (auction_type== 1)
//**
//**     {Alert(\"check2\");
//**      A1_upto=parseInt (rowValue[12]);
//**       Alert(\"check3\");
//**      A1_current=parseInt (rowValue[8]);
//**       Alert(\"check4\");
//**      A1_reset=rowValue[16];
//**       if (A1_reset != \"null\")
//**         {Alert(\"check5\");
//**          A1reset_go=\'true\';
//**          };
//**       if (A1_reset == \"null\") and (A1reset_go==\'true\')
//**         {Alert(\"check6\");
//**          A1reset_go=false;
//**          Alert(\"check7\"); 
//**          A1_start=rowValue[8];
//**          };
//**        if  ((A1_current - A1_start) <= (A1_upto - 10))
//**          {Alert(\"check8\");
//**           BidClick1 ();
//**           };
//**      };

//** end my part

      };
    );
}


//--- Format our special cell with CSS.  Add \"visibility: hidden;\" or \"display: none;\",if desired.
GM_addStyle ( (<><![CDATA[
    #LatestJSON_Data
    {
        background:         gold;
        border:             3px ridge #0000DD;
        font-size:          10px;
        margin:             0 2em;
        padding:            1ex 1em;
        width:              94%;
        opacity:            0.8;
        overflow:           hidden;
        z-index:            666;
        position:           absolute;
        color:              black;
    }
]]></>).toString () );
基本上,到目前为止,它确实创建了一个单元格,在其中显示放入数组“ 1”的所有拍卖数据。 我想使用每秒更新一次的数组中的数据来获取某些数据,然后决定是否单击“出价”按钮。 对于第一次拍卖,我停了下来。计时器拍卖使我能够每隔几秒钟单击一次。 在第一次拍卖中,我基本上想: 检查它是哪个拍卖, 找出这是否是第一次竞价, 获得最高出价, 进行计算以开始单击拍卖的最后10次点击。 重置起始金额。 听起来很简单,但是没有调试器并且对Js和GM的了解很少,这让我很忙。我曾尝试将Var放在控制台日志中,但是无法跟踪它们。可能是错误地声明了它们,或者错误地使用了它们……但是我看不到错误,并且我没有调试器来测试它们。 Java调试器可以工作吗?但它没有链接到该网站... 另外,当我将零件添加到Brock的代码中时,它不再显示带有信息的单元格...所以在我破坏了他的代码的地方,我找不到问题了...在我添加任何内容之前他的代码,效果很好,然后我添加了我的部件,它不再起作用了,所以我使用\“ // \”将其取出。因此脚本应该跳过它,但是他的部分不再起作用。我尝试添加“警报”,但似乎找不到问题。我所有的零件都标有\“ // ** \”,目前应该处于无效状态。 任何帮助将不胜感激。谢谢     

解决方法

        好吧,我没有从这里得到很多答复,但是我已经尝试过...:((我设法将它调试了90%,但这是我的回答sofer ...在我找到一种方法后将对其进行更新引起小故障..:
// ==UserScript==
// @name            let\'s try 3.42
// @include         http://www.trada.net/*
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// ==/UserScript==
var auctiontyp = 0;var aupto = 0;var A1_start  = 0;var A1_current = 0;var A1_rest= \'x\';
// **bid function and var\'s
var interval            = 50;
var bidClickTimer       = setInterval (function() {BidClick1 (); },interval);
var numBidClicks        = 0;
var A1reset_go          = false;

function BidClick1 ()

{var bidBtn1=document.getElementById(\"ctl00_mainContentPlaceholder_AirtimeAuctionItem1_btn_BidButton\");


    numBidClicks++;
    if (numBidClicks > 3)
    {   alert(\"check10\");
       clearInterval (bidClickTimer);
        bidClickTimer   = \"\";
    }
    else
    {   alert(\'check11\');
        //bidBtn1.click (1);

    }
};



// end bid function

var myJson              = \'{\"d\":[[\"\",\"\",\"y\",\"ZAR\",\"1\",\"49517\",\"6458,8270,7635\",null,\"1.40\",\"6458\",\"0:13:30\",\"12\",\"C\",\"30\",null],[\"y\",\"-00:00\",\"2\",\"49593\",6458,6458\",\"2.92\",\"0:13:37\",\"L\",\"Ve4mYdrvkkQMKxBH1\\/1VMtDTCDQBRspg5jB8jjY08zg=\"],[\"\",\"3\",\"49058\",\"7456,9216,5153,7456\",\"194.40\",\"7456\",\"0:00:31\",\"1100\",\"T\",\"4\",\"49597\",\"2935,6554\",\"1.22\",\"2935\",\"0:01:16\",\"5\",\"49590\",\"4440,0518,5343,2625,4848\",\"0.95\",\"4440\",\"0:15:58\",\"6\",\"49591\",\"4848,4440,2625\",\"1.81\",\"4848\",\"0:16:05\",\"7\",\"49595\",\"5.55\",\"0:04:13\",\"55\",\"8\",\"49596\",\"2.90\",\"NONE\",\"0:04:35\",\"29\",\"9\",\"49496\",2427,7863,5845\",\"2.56\",\"0:06:07\",\"10\",\"B\",\"49524\",\"1.67\",\"0:06:00\",\"11\",\"49539\",0764\",\"2.02\",\"0:04:25\",null]]}\'
var jsonObj             = $.parseJSON (myJson);

//--- The JSON should return a 2-D array,named \"d\".
var arrayOfAuctions     = jsonObj.d;

//--- Loop over each row in the array.
$.each (
    arrayOfAuctions,function (rowIndex,singleAuctionData) {

        //--- Print the 7th column.
        console.log (\'Row: \' + (parseInt (rowIndex) + 1) + \' Column: 7  Value: \' + singleAuctionData[6]);
alert(\'test3.41\');
auctiontyp=parseInt (singleAuctionData[4]);
   if (auctiontyp== 1)

     {
   aupto=parseInt (singleAuctionData[15]);alert(\'check2.6\');
       alert(\'check3 \'+(singleAuctionData[8]));
      A1_current=parseFloat (singleAuctionData[8]);
      alert(\'check4 \'+(singleAuctionData[16]));
      A1_rest=singleAuctionData[16];
       alert(A1_rest);
       if (A1_rest != \'null\')
         {alert(\'check5\');
          A1reset_go=true;
          };
       alert(\'check5.1\');
       alert(A1reset_go);
       if (A1_rest == \'null\') and (A1reset_go==true)
         {alert(\'check6\');
          A1reset_go=false;
          alert(\'check7\'); 
          A1_start=singleAuctionData[8];
         };
          alert(\'check7.3\');
         alert((A1_current) );
         alert(( A1_start));
         alert((aupto) );
        if  (((A1_current - A1_start)*100) < (aupto - 10))
          {alert(\'check8\');
           //BidClick1 ();
           };

     };
    }
);
我目前在此脚本上遇到的问题: 1。\“ BidClick1 \”函数在脚本的开头运行而不被调用,我只在结尾附近调用它,但随后它没有运行。 2.本部分:
A1_rest=singleAuctionData[16];
           alert(A1_rest);
           if (A1_rest != \'null\')
             {alert(\'check5\');
              A1reset_go=true;
              };
           alert(\'check5.1\');
           alert(A1reset_go);
           if (A1_rest == \'null\') and (A1reset_go==true)
             {alert(\'check6\');
              A1reset_go=false;
              alert(\'check7\'); 
              A1_start=singleAuctionData[8];
             };
未正确执行。对于此数组,“ arrayOfAuctions \”,在第一个段上,我对\“ A1_rest \”进行的所有测试应= = \“ null \”,但不是,因此它执行:\“
if (A1_rest != \'null\')
                 {alert(\'check5\');
                  A1reset_go=true;
                  };\" 
而且,它不执行以下语句: \“
 if (A1_rest == \'null\') and (A1reset_go==true)
                 {alert(\'check6\');
                  A1reset_go=false;
正确地,它仅应在A1_rest = \“ null \”并且A1_reset_go为true时执行。无论哪一个为真,它都会执行,如果我将其表示为:
if ((A1_rest == \'null\') and (A1reset_go==true))
,它根本不会运行该脚本。 如果有任何一个完整的答案,我会这样标出来。 谢谢。                   警报(\'check7 \');                   A1_start = singleAuctionData [8];                  }; \“总是执行     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-