$ is not defined 虽然不影响实际运行,但是看上去非常不爽。 在代码头部插入 var $ = unsafeWindow.jQuery; 即可解决。 另一种情况,确实是没有引入 jQuery 例如, unsafeWindow.jQuery 也是 null,说明页面并没有引入 jQuery。 这时就需要在 tampermonkey 中指定引入 jQuery。例如: // @
@grant 被用于设置 GM_* 函数的白名单, GM_*function 是一些 unsafeWindow 对象和一些有影响的 window 函数,如果没有 @grant 标签,TM 会无法调用 GM_* 函数。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 // @grant GM_setValue// @grant GM_getValue// @grant GM_setClipboard// @grant unsafe...
full unsafeWindow access all GM_* functions including (GM_registerMenuCommand, GM_getResourceText, GM_getResourceURL, GM_notification) a lot of tags supported by Greasemonkey and Scriptish (like @resource, @require, ...) For a full overview please take a look at the FAQ or just install TM...
原页面中已引入 jQuery, 但是 tampermonkey 编辑器中总是提示 $ is not defined 虽然不影响实际运行,但是看上去非常不爽。在代码头部插入 var $ = unsafeWindow.jQuery; 即可解决。另一种情况,确实是没有引入 jQuery 例如, unsafeWindow.jQuery 也是 null,说明页面并没有引入 jQuery。这时就需要在 tampermonkey 中指...
(Please fill out the issue template with your details) Expected Behavior I should not see an error: "ReferenceError: MutationEvent is not defined" in the JavaScript debug console Actual Behavior I see an error: "ReferenceError: MutationE...
(function() { 'use strict'; unsafeWindow.Vue = Vue // replace window with unsafeWindow Vue.createApp({ data() { return { foo: 'bar' } }, template: '{{ foo }}' }).mount('#app'); })(); replacing window with unsafeWindow seems work.Sign...
full unsafeWindow access all GM_* functions including (GM_registerMenuCommand, GM_getResourceText, GM_getResourceURL, GM_notification) a lot of tags supported by Greasemonkey and Scriptish (like @resource, @require, ...) For a full overview please take a look at the FAQ or just install TM...
unsafeWindow.location.href = "https://www.sunzhongwei.com/#/sleeping"; }, 3000); hash # 更改并不会触发页面从服务器重新加载 使用angular, vue 之类的前端框架写过单页面 web app 都知道,hash # 的更改并不会导致页面从服务器重新加载页面。也就不会触发 tampermonkey 的脚本从头执行。
unsafeWindow.alert = function(){return false}; window.alert = function(){return false}; Window.prototype.alert = function(){return false}; 效果 如此,alert 窗口就不会再弹出了。 confirm 窗口 类似,如果想自动跳过 confirm 窗口,也是类似修改。
爆出函数未定义的错误Function is not defined。在mozillazine了解到Tampermonkey的js脚本是在sandbox中的,在html中访问不到。使用下面的例子可以完成这个功能 unsafeWindow.abc = function(msg) { alert(msg); }; document.getElementById("a").onclick = "window.abc('helloWorld')"; 2、跨域访问 在http://m...