我一直在尝试将一个用户脚本迁移到我的扩展程序中,但出于某些原因,我无法运行以下代码:
// ==/UserScript==
console.info('BEFORE Hooked! MONKEY');
(function() {
'use strict';
// Reference [Augular loaded detect]: https://dev59.com/yI7da4cB1Zd3GeqP7gMY#31970556
var initWatcher = setInterval(function () {
if (window.MegaUtils) {
console.info(window.MegaUtils);
clearInterval(initWatcher);
hookImport();
hookFull();
console.info('FUNtions Hooked! MONKEY');
}
}, 500);
})();
因此,完全没有检测到window.MegaUtils,而我不知道原因。有人告诉我,我的扩展程序可能无法访问DOM对象,但为什么ViolentMonkey可以访问它。
这是我在Chrome中导入扩展程序时使用的清单:
{
"manifest_version": 2,
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js": [ "mega.user.js" ],
"matches": [ "https://mega.nz/*",
"http://mega.nz/*" ],
"run_at": "document_end"
} ],
"converted_from_user_script": true,
"description": "testing extension",
"permissions": [],
"name": "MegaByPass",
"icons": {
"16": "images/mega-cloud-icon.png",
"32": "images/mega-cloud-icon.png",
"48": "images/download.png",
"128": "images/873133.png"
},
"version": "1.0"
}
先感谢一下。
manifest.json
还是tabs.executeScript
或者contentScripts.register()
或者userScripts.register()
等方式呢? - erosman