Major 发表于 2022-1-28 11:39:46

脚本猫的脚本不运行了

本帖最后由 Major 于 2022-1-28 12:09 编辑

如图,脚本能识别目标网站,但是脚本实际上并未运行.关闭脚本猫重启,或者卸载重新安装都试了,都未能解决问题。




脚本代码:


// ==UserScript==
// @name         【蛮吉】京东快递
// @namespace    http://tampermonkey.net/
// @version      0.0.0
// @descriptiontry to take over the world!
// @author       You
// @match      *jd.com*
// @match      https://www.jd.com*
// @grant      GM_xmlhttpRequest
// @connect      
// run-at      document-idle
// ==/UserScript==



(function() {
    // 创建页面悬浮元素
    alert('脚本开始了--------------')
    let div=document.createElement("div");
    div.innerHTML=(" <div style='left: 1px;bottom: 10px;background: #1a59b7;color:#ffffff;overflow: hidden;z-index: 9999;position: fixed;padding:5px;text-align:center;width: 40px;height: 50px;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;'><button id = 'time1'>开始</button><button id = 'time2'>结束</button></div>");
    document.body.append(div);

});


李恒道 发表于 2022-1-28 11:46:46

图没贴上来哦,哥哥

Major 发表于 2022-1-28 12:09:58

李恒道 发表于 2022-1-28 11:46
图没贴上来哦,哥哥

图贴了,代码也放了,能看到是什么问题吗

Ne-21 发表于 2022-1-28 12:19:50

本帖最后由 Ne-21 于 2022-1-28 12:23 编辑

```javascript
// ==UserScript==
// @name         【蛮吉】京东快递
// @namespace    http://tampermonkey.net/
// @version      0.0.0
// @descriptiontry to take over the world!
// @author       You
// @match      *jd.com*
// @match      *://*jd.com*
// @grant      GM_xmlhttpRequest
// @connect
// @run-at      document-idle
// ==/UserScript==



(function() {
    // 创建页面悬浮元素
    alert('脚本开始了--------------')
    let div=document.createElement("div");
    div.innerHTML=(" <div style='left: 1px;bottom: 10px;background: #1a59b7;color:#ffffff;overflow: hidden;z-index: 9999;position: fixed;padding:5px;text-align:center;width: 40px;height: 50px;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;'><button id = 'time1'>开始</button><button id = 'time2'>结束</button></div>");
    document.body.append(div);

})();
```

Ne-21 发表于 2022-1-28 12:23:11

你函数有问题
你是这样写的

```javascript
(function(){});
```

正确的应该这样写

```javascript
(function(){})();
```

也就是说,你函数写了但是并没有去执行他

Major 发表于 2022-1-28 12:32:36

Ne-21 发表于 2022-1-28 12:19
```javascript
// ==UserScript==
// @name         【蛮吉】京东快递


感谢! 感谢!感谢!

李恒道 发表于 2022-1-28 14:10:06

Ne-21 发表于 2022-1-28 12:23
你函数有问题
你是这样写的



哥哥牛逼!

涛之雨 发表于 2022-1-28 17:36:42

(诈尸)
看到标题第一反应感觉是从英语翻译过来的。。。
(英语:script in scriptcat doesn't work)
(翻译:脚本猫的脚本不运行了)

李恒道 发表于 2022-1-28 19:50:39

涛之雨 发表于 2022-1-28 17:36
(诈尸)
看到标题第一反应感觉是从英语翻译过来的。。。
(英语:script in scriptcat doesn't work)


涛,这是什么时代!
页: [1]
查看完整版本: 脚本猫的脚本不运行了