Script Menu 作者: yobukodori
实验性实验性
可在 Android™ 版 Firefox 上使用可在 Android™ 版 Firefox 上使用
Select and run the registered JavaScript (userscript) from the menu. Works on Android as well as on PC. I developed this extension for Firefox for Mobile where the bookmarklets is not available. 登録したスクリプトをメニューから選択して実行します。Androidでも機能します
您需要 Firefox 来使用此扩展
扩展元数据
屏幕截图
关于此扩展
Select and run the registered JavaScript (userscript) from the menu. Using browser.tabs.executeScript API.
Works on Android as well as on PC. I developed this extension for Firefox for Mobile where the bookmarklets is not available.
Usage
screenshot
Works on Android as well as on PC. I developed this extension for Firefox for Mobile where the bookmarklets is not available.
Usage
screenshot
- Show menu in page: Show menu in page for quick access to the menu on Android.
- Print debug info: Output debug information at the bottom of the Options tab.
- Add line numbers: Add line numbers to script resource.
- Script Resource: Script to register in the menu.
- Script Resource must not begin with a non-directive line, such as a blank line. Always start with a specific directive line.
- Each script begins with the //name directive.
The //name directive specifies the script name to be displayed on the menu.
//name Go page top - The //matches directive specifies a comma-separated list of URL patterns for the pages where you want to display the script name. (Optional)
//matches https://www.google.com/*, https://github.com/*
- The //exclude directive specifies a comma-separated list of URL patterns for the pages where you don't want to display the script name. (Optional)
The //exclude directive has a higher priority than the //matches directive.//exclude https://yobukodori.github.io/*, https://github.com/yobukodori/*
- The //option directive specifies a comma-separated list of tokens (Optional). The following tokens are available.
//option page, all, blank
- nonce: Sets
true
towrapCodeInScriptTag
andnonce
. - page: Sets true to
wrapCodeInScriptTag
. - all: Sets true to
allFrames
. - blank: Sets true to
matchAboutBlank
. See the following //options directive for options.
- nonce: Sets
- The //options directive sets details. (Optional)
//options
{
"allFrames": true,
"wrapCodeInScriptTag": true
}
wrapCodeInScriptTag is a Script Menu specific option. If its value is true, the code is wrapped in a script tag and executed. Then you can access the variables/functions/objects, etc. defined by page script.
Internally convert it to the following code and execute it.
nonce option is used with wrapCodeInScriptTag to set the nonce attribute on the script tag.
(function() {
let e = document.createElement("script");
e.append(<your code>);
e.nonce = <nonce value>; // Set if nonce option is true.
document.documentElement.appendChild(e);
e.remove();
})();
For example, twitter.com restricts script execution with Content Security Policy nonce-source. To run code in the context of a page script:
//name xhr logger
//matches *://twitter.com/*
//; The next option should be 'nonce'. Specifying 'page' will fail.
//option nonce
//js
XMLHttpRequest.prototype.open = new Proxy(XMLHttpRequest.prototype.open, {
apply: function(target, thisArg, args ) {
console.log(args[0], args[1]);
return Reflect.apply(target, thisArg, args);
}
});
You can also use comment style or comma expression style so that it will not cause an error when executed as javascript.
//options
/* { "wrapCodeInScriptTag": true } */
or
//options
0, { "wrapCodeInScriptTag": true } - Content scripts and Page scripts
See Content script environment.
This add-on executes the code as a content scripts.
To execute the code in the context of a page scripts, inject a script tag that wraps the code. The option wrapCodeInScriptTag does this for you.
Without wrapCodeInScriptTag option
[advantage]
- Can execute external script file specified in the //js section without CSP restrictions.
- Can read cross-origin resources with xhr/fetch without CORS restrictions.
- Can't access the variables/functions/objects, etc. defined by the page script.
You can access the variables/functions/objects, etc. defined by the page scripts. However, the above restrictions of CSP and CORS will apply. - Finally, write the code with the //js directive.
[NOTE] Doesn't check the syntax of the code, so please paste the code that has been tested to work.
//js
(function(){
alert("hello");
})(); - Simply write the URL and you can execute the script.
This add-on itself reads the script from the URL and executes the loaded code.
[NOTE] If you want to access the variables/functions/objects, etc. defined by the page script, specify wrapCodeInScriptTag in the //options directive.
//js
https://yobukodori.github.io/foo.js - Prepared the following built-in scripts for Fenix.
//name View Page Source
//js
builtin:view-page-source
//name View (Selected) outerHTML
//js
builtin:view-outerhtml - //module directive and //require directive
//module: define module.
//require: import module or external script file. Can import multiple modules.
//module libA
//js
function foo(){ console.log("foo"); }
function bar(){ console.log("bar"); }
//module libB
//js
function baz(){ console.log("baz"); }
//name item-1
//require libA
//js
foo();
//name item-2
//require libA, libB
//js
bar(); baz();
//name item-3
//require https://code.jquery.com/jquery-2.2.4.min.js
//js
console.log(typeof $); - //#include preprocess-directive replaces this line with the contents of the file at the given url.
You can specify any part of the script resource as it is simply replaced before parsing.
//#include https://yobukodori.github.io/scrip-menu-item.js - Other directives. (Optional)
//disable: disable this script. In case you don't use the script but want to keep it.
//eof: Ignore the lines that follow.
//[-=*;#]: Comment line. Excluding //#include.
//name Obsolete script
//disable
//js
(function(){/* code */})();
//===============================
//name Beautify the page
//# comment
//js
(function(){/* code */})();
//eof
#############################
[memo]
...
[todo]
...
- Go to line: Move the cursor to the specified line.
- Go to Script...: Move the cursor to the start of each script.
- Save: Save settings and scripts resource. And apply settings and scripts.
- Apply: Apply settings and scripts. (doesn't save).
- Get Status: get current status and applied scripts.
- Clear Log: Clear log.
为您的体验打分
权限详细了解
此附加组件需要:
- 存取浏览器标签页
- 获知浏览器导航时的行为状态
- 存取您在所有网站的数据
更多信息
- 附加组件链接
- 版本
- 0.3.0
- 大小
- 30.89 KB
- 上次更新
- 9 个月前 (2024年2月28日)
- 相关分类
- 许可证
- Mozilla 公共许可证 2.0
- 隐私政策
- 阅读此附加组件的隐私政策
- 版本历史
添加到收藏集
yobukodori 制作的更多扩展
- 目前尚无评分
- 目前尚无评分
- 目前尚无评分
- 目前尚无评分
- 目前尚无评分
- 目前尚无评分