Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]js依赖不能使用,存在问题。 #190

Closed
yang10560 opened this issue May 25, 2023 · 7 comments
Closed

[bug]js依赖不能使用,存在问题。 #190

yang10560 opened this issue May 25, 2023 · 7 comments

Comments

@yang10560
Copy link

我引入

// @require    https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js

 async function digestMessage(r) {
        const hash = CryptoJS.SHA256(r);
        return hash.toString(CryptoJS.enc.Hex);
    }

不能够直接使用CryptoJS,提示不存在。但在tampermonkey管理器是可以使用的。看了你网站api文档并没有说什么,还是说要别的引入方法呢?

@yang10560 yang10560 changed the title js依赖不能使用,存在问题。 [bug]js依赖不能使用,存在问题。 May 25, 2023
@yang10560
Copy link
Author

我又测在另一个脚本单独引入一个是可以正常使用。但我引入多个就不行了?有点奇怪。
脚本地址:https://scriptcat.org/script-show-page/1043

@yang10560
Copy link
Author

又经过测了谷歌网站,没问题。可能是百度的问题,不清楚为啥不可以在百度上运行,请排查一下

@CodFrm
Copy link
Member

CodFrm commented May 27, 2023

关于引入那里,有完整的示例么?

我现在先看看该脚本在百度上的运行情况

@yang10560
Copy link
Author

关于引入那里,有完整的示例么?

我现在先看看该脚本在百度上的运行情况

以下一个例子。在tampermonkey中可以正常运行。

// ==UserScript==
// @name         测试引入js
// @namespace    http://tampermonkey.net/
// @version      1.1.1
// @description  测试js
// @author       夜雨
// @match      *://*/*
// @run-at     document-end
// @require    https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js
// @require    https://cdn.bootcdn.net/ajax/libs/marked/4.3.0/marked.min.js
// @require    https://cdn.bootcdn.net/ajax/libs/markdown-it/13.0.1/markdown-it.min.js
// @require    https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js
// @require    https://cdn.bootcdn.net/ajax/libs/highlight.js/11.7.0/highlight.min.js
// @require    https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
// @require    https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.4/katex.min.js
// @license    MIT


// ==/UserScript==

(function(){
    let pt = CryptoJS.AES.encrypt(JSON.stringify({data:"测试"}),'806.i4.dds764&65eyeadnf').toString()
    console.log(pt)
    new showdown.Converter(); 
    
})();

@CodFrm
Copy link
Member

CodFrm commented May 27, 2023

我这里没有报错,脚本猫会产生什么结果呢?也许是bug,因为网络波动导致js文件没有下载下来,可以在工具,脚本资源看一下是不是有加载成功:
image

image

@CodFrm
Copy link
Member

CodFrm commented May 27, 2023

示例问题修复了,但是脚本依旧无法使用,我使用tampermonkey在百度中好像也有问题

@CodFrm
Copy link
Member

CodFrm commented May 27, 2023

百度中无法使用是我的广告屏蔽插件导致的,关闭都可以正常使用了

@CodFrm CodFrm closed this as completed May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants