这是 Greasy Fork 将读取的 用户脚本属性值 的一个列表。不在此列表的属性也可以写在脚本中,那些不在此列表的属性值也会包含在用户安装的脚本中,但是并不会对 Greasy Fork 上的脚本页面做任何变动。
§@name
脚本的名称。该项将显示在页面的标题以及链接内容,必填项。
§@name:XX-YY
脚本在特定语言区域的标题。XX 指 ISO 639-1 国家代码 以及 YY 指可选的 ISO 3166 地区代码。该选项用于提供多语言的@name
脚本名称。
§@description
脚本功能的描述,显示在脚本标题下面,必填项。
§@description:XX-YY
用某门语言写成的脚本描述。XX 指 ISO 639-1 国家代码 以及 YY 指可选的 ISO 3166 地区代码。该选项用于提供多语言的@description
脚本介绍。
§@namespace
@namespace
与 @name
这两个属性被作为脚本的唯一标识符,用户脚本管理器根据它们来判断一个脚本是否已安装。Greasy Fork 也需要这些属性,若用户在更新脚本时改变了两者中的任意一项,将发出警告。
§@version
脚本的版本标记将使用 Mozilla 版本格式,并显示于脚本的简介页面。Greasy Fork 要求填写该属性,且当用户更新脚本时没有更新版本号或降低了版本号时将发出警告。
§@include
, @exclude
, @match
描述脚本会在哪些网站上运行。该列表会被解析和展示到脚本的简介页面,并用于脚本的分类。每个脚本须有至少一个 @match
或 @include
。了解格式细则。
§@require
引入外部脚本到用户脚本。查看关于引入外部脚本到代码的规则。如果你使用 SRI(Sub-Resource Integrity) 来记录外部脚本哈希(更多信息请参阅 TamerMonkey 文档 与 MDN 文档),当 SRI 与文件的实际哈希不一致时将会在 Greasy Fork 进行警告。
§@resource
引入外部资源(如 JavaScript、CSS、图像等)到脚本。查看关于引入外部脚本到代码的规则。如果你使用 SRI(Sub-Resource Integrity) 来记录外部脚本哈希(更多信息请参阅 TamerMonkey 文档 与 MDN 文档),当 SRI 与文件的实际哈希不一致时将会在 Greasy Fork 进行警告。
§@updateURL
, @installURL
, @downloadURL
告知用户脚本管理器应该在哪个地址获取脚本更新。Greasy Fork 将自动修改该属性使其永远通过 Greasy Fork 进行更新。
§@license
许可证描述的是您是否允许别人以某些形式复制或修改您的脚本。建议从 SPDX 许可证列表 中选择「Full name」或「Identifier」填至此处。若您不提供许可证,则表示脚本仅允许个人使用且不得二次分发。许可证将在脚本的简介页面显示。
§@supportURL
该脚本的技术支持链接(如:错误反馈系统、论坛、电子邮箱地址等),该链接将显示在脚本的反馈页面。
§@contributionURL
用于捐赠脚本作者的链接,该链接将显示在脚本的反馈页面。网址可以为 http、https 或比特币协议的网址。如果您需要链接到贝宝捐赠页面,请使用例如 https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=your.email.here@example.com&item_name=Greasy+Fork+donation 这样的格式,替换为您自己的邮箱地址即可。
§@contributionAmount
建议捐赠金额,请配合 @contributionURL
使用。
§@compatible
标记此脚本与某个浏览器兼容,兼容性信息将显示在脚本的简介页面上。您也可以添加额外的兼容说明,如 @compatible firefox 火狐上必须关闭广告过滤器
这样的格式。目前能被网站识别的浏览器名称有:firefox
, chrome
, opera
, safari
, edge
。
§@incompatible
标记此脚本与某个浏览器不兼容,兼容性信息将显示在脚本的简介页面上。您也可以添加额外的兼容说明,如 @incompatible firefox 自火狐 23 开始不兼容
这样的写法。目前能被网站识别的浏览器名称有:firefox
, chrome
, opera
, safari
, edge
。
§@antifeature
披露会为脚本作者而非用户带来额外收益的功能。你可以通过在脚本的元数据中添加 @antifeature type description
值的方法披露。其中type(类型)是必须填写的内容,而 description(描述)则可以留空。点击此处了解 Greasy Fork 读取的 type(类型)的相关信息。
§@antifeature:XX-YY
你可以使用多种语言声明 @antifeature
属性,其中 XX 为 ISO 639-1 中定义的两个字符的代码,而 YY 则是一个可选的 ISO 3166 中定义的国家代码。在@antifeature
中制定的每一个类型都可以自定义其本地化的说明。
@homepage, @homepageURL, @website and @source
@icon, @iconURL and @defaulticon
GM_addElement(tag_name, attributes), GM_addElement(parent_node, tag_name, attributes)
GM_addValueChangeListener(name, function(name, old_value, new_value, remote) {})
GM_removeValueChangeListener(listener_id)
GM_getValue(name, defaultValue)
GM_registerMenuCommand(name, fn, accessKey)
GM_unregisterMenuCommand(menuCmdId)
GM_openInTab(url, options), GM_openInTab(url, loadInBackground)
GM_download(details), GM_download(url, name)
GM_notification(details, ondone), GM_notification(text, title, image, onclick)GM_setClipboard(data, info)
The name of the script.
Internationalization is done by adding an appendix naming the locale.
Code:
// @name A test// @name:de Ein Test
The namespace of the script.
The script version. This is used for the update check, in case the script is not installed from userscript.org or TM has problems to retrieve the scripts meta data.
The scripts author.
A short significant description.
Internationalization is done by adding an appendix naming the locale.
Code:
// @description This userscript does wonderful things// @description:de Dieses Userscript tut wundervolle Dinge
The authors homepage that is used at the options page to link from the scripts name to the given page. Please note that if the @namespace tag starts with 'http://' its content will be used for this too.
The script icon in low res.
This scripts icon in 64x64 pixels. If this tag, but @icon is given the @icon image will be scaled at some places at the options page.
An update URL for the userscript. Note: a @version tag is required to make update checks work.
Defines the URL where the script will be downloaded from when an update was detected. If the value none is used, then no update check will be done.
Defines the URL where the user can report issues and get personal support.
The pages on that a script should run. Multiple tag instances are allowed.
@include doesn't support the URL hash parameter. You have to match the path without the hash parameter and make use of window.onurlchange Note: When writing something like *://tmnk.net/*
many script developers expect the script to run at tmnk.net
only, but this is not the case. It also runs at https://example.com/?http://tmnk.net/
as well. Therefore Tampermonkey interprets @includes that contain a ://
a little bit like @match. Every *
before ://
only matches everything except :
characters to makes sure only the URL scheme is matched. Also, if such an @include contains a /
after ://
, then everything between those strings is treat as host, matching everything except /
characters. The same applies to *
directly following ://
.
Code:// @include http://www.tampermonkey.net/*// @include http://*// @include https://*// @include /^https:\/\/www\.tampermonkey\.net\/.*$/ // @include *
|
|
---|---|
More or less equal to the @include tag. You can get more information here . Note: the '<all_urls>' statement is not yet supported and the scheme part also accepts 'http*://'.
Multiple tag instances are allowed.
Exclude URLs even it they are included by @include or @match .
Multiple tag instances are allowed.
Points to a JavaScript file that is loaded and executed before the script itself starts running. Note: the scripts loaded via @require and their "use strict" statements might influence the userscript's strict mode!
Code:
// @require https://code.jquery.com/jquery-2.1.4.min.js// @require https://code.jquery.com/jquery-2.1.3.min.js#sha256=23456...// @require https://code.jquery.com/jquery-2.1.2.min.js#md5=34567...,sha256=6789...// @require tampermonkey://vendor/jquery.js// @require tampermonkey://vendor/jszip/jszip.js
Please check the sub-resource integrity section for more information how to ensure integrity. Multiple tag instances are allowed.
Preloads resources that can by accessed via GM_getResourceURL and GM_getResourceText by the script.
Code:
// @resource icon1 http://www.tampermonkey.net/favicon.ico// @resource icon2 /images/icon.png// @resource html http://www.tampermonkey.net/index.html// @resource xml http://www.tampermonkey.net/crx/tampermonkey.xml// @resource SRIsecured1 http://www.tampermonkey.net/favicon.ico#md5=123434...// @resource SRIsecured2 http://www.tampermonkey.net/favicon.ico#md5=123434...;sha256=234234...
Please check the sub-resource integrity section for more information how to ensure integrity. Multiple tag instances are allowed.
This tag defines the domains (no top-level domains) including subdomains which are allowed to be retrieved by GM_xmlhttpRequest
Code:
// @connect <value>
can have the following values:
If it's not possible to declare all domains a userscript might connect to then it's a good practice to do the following: Declare all known or at least all common domains that might be connected by the script. This way the confirmation dialog can be avoided for most of the users.
Additionally add "@connect *" to the script. By doing so Tampermonkey will still ask the user whether the next connection to a not mentioned domain is allowed, but also offer a "Always allow all domains" button. If the user clicks at this button then all future requests will be permitted automatically.
Users can also whitelist all requests by adding '*' to the user domain whitelist at the script settings tab.
Notes:
Multiple tag instances are allowed.
Defines the moment the script is injected. In opposition to other script handlers, @run-at defines the first possible moment a script wants to run. This means it may happen, that a script that uses the @require tag may be executed after the document is already loaded, cause fetching the required script took that long. Anyhow, all DOMNodeInserted and DOMContentLoaded events that happended after the given injection moment are cached and delivered to the script when it is injected.
Code:
// @run-at document-start
The script will be injected as fast as possible.
Code:
// @run-at document-body
The script will be injected if the body element exists.
Code:
// @run-at document-end
The script will be injected when or after the DOMContentLoaded event was dispatched.
Code:
// @run-at document-idle
The script will be injected after the DOMContentLoaded event was dispatched. This is the default value if no @run-at tag is given.
Code:
// @run-at context-menu
The script will be injected if it is clicked at the browser context menu (desktop Chrome-based browsers only). Note: all @include and @exclude statements will be ignored if this value is used, but this may change in the future.
@grant is used to whitelist GM_* functions, the unsafeWindow object and some powerful window functions. If no @grant tag is given TM guesses the scripts needs.
Code:
// @grant GM_setValue// @grant GM_getValue// @grant GM_setClipboard// @grant unsafeWindow// @grant window.close// @grant window.focus// @grant window.onurlchange
Since closing and focusing tabs is a powerful feature this needs to be added to the @grant statements as well.
If a script runs on a single-page application, then it can use window.onurlchange to listen for URL changes:
Code:
// ==UserScript==...// @grant window.onurlchange// ==/UserScript==if (window.onurlchange === null) { // feature is supported window.addEventListener('urlchange', (info) => ...);}
If @grant is followed by 'none' the sandbox is disabled and the script will run directly at the page context. In this mode no GM_* function but the GM_info property will be available.
Code:
// @grant none
This tag allows script developers to disclose whether they monetize their scripts. It is for example required by GreasyFork.
Syntax:
can have the following values:
Code:
// @antifeature ads We show you ads// @antifeature:fr ads Nous vous montrons des publicités// @antifeature tracking We have some sort of analytics included// @antifeature miner We use your computer's resources to mine a crypto currency
Internationalization is done by adding an appendix naming the locale.
This tag makes the script running on the main pages, but not at iframes.
Injects the userscript without any wrapper and sandbox into the page, which might be useful for Scriptlets.
The unsafeWindow object provides full access to the pages javascript functions and variables.
The hash component of the URL of @resource and @require tags can be used for this purpose.
Code:
// @resource SRIsecured1 http://www.tampermonkey.net/favicon1.ico#md5=ad34bb...// @resource SRIsecured2 http://www.tampermonkey.net/favicon2.ico#md5=ac3434...,sha256=23fd34...// @require https://code.jquery.com/jquery-2.1.1.min.js#md5=45eef...// @require https://code.jquery.com/jquery-2.1.2.min.js#md5-ac56d...,sha256-6e789...// @require https://code.jquery.com/jquery-3.6.0.min.js#sha256-/xUj+3OJU...ogEvDej/m4=
TM supports SHA-256 and MD5 hashes natively, all other (SHA-1, SHA-384 and SHA-512) depend on window.crypto. In case multiple hashes (separated by comma or semicolon) are given the last currently supported one is used by TM. If the content of the external resource doesn't match the selected hash, then the resource is not delivered to the userscript.
All hashes need to be encoded in hex or Base64 format.
Adds the given style to the document and returns the injected style element.
Creates an HTML element specified by 'tag_name' and applies all given 'attributes' and returns the injected HTML element. If a 'parent_node' is given, then it is attached to it or to document head or body otherwise.
For suitable 'attributes', please consult the appropriate documentation. For example:
Code:
GM_addElement('script', { textContent: 'window.foo = "bar";'});GM_addElement('script', { src: 'https://example.com/script.js', type: 'text/javascript'});GM_addElement(document.getElementsByTagName('div')[0], 'img', { src: 'https://example.com/image.png'});GM_addElement(shadowDOM, 'style', { textContent: 'div { color: black; };'});
Note: this feature is experimental and the API may change.
Deletes 'name' from storage.
List all names of the storage.
Adds a change listener to the storage and returns the listener ID. 'name' is the name of the observed variable. The 'remote' argument of the callback function shows whether this value was modified from the instance of another tab (true) or within this script instance (false). Therefore this functionality can be used by scripts of different browser tabs to communicate with each other.
Removes a change listener by its ID.
Set the value of 'name' to the storage.
Get the value of 'name' from storage.
Log a message to the console.
Get the content of a predefined @resource tag at the script header.
Get the base64 encoded URI of a predefined @resource tag at the script header.
Register a menu to be displayed at the Tampermonkey menu at pages where this script runs and returns a menu command ID. As of Tampermonkey 4.14 'fn' get a MouseEvent or KeyboardEvent as argument.
Unregister a menu command that was previously registered by GM_registerMenuCommand with the given menu command ID.
Open a new tab with this url. The options object can have the following properties:
Otherwise the new tab is just appended. loadInBackground has the opposite meaning of active and was added to achieve Greasemonkey 3.x compatibility. If neither active nor loadInBackground is given, then the tab will not be focused. This function returns an object with the function close, the listener onclose and a flag called closed.
Make an xmlHttpRequest.
Property of details:
method one of GET, HEAD, POST
url the destination URL
headers ie. user-agent, referer, ... (some special headers are not supported by Safari and Android browsers)
data some string to send via a POST request
cookie a cookie to be patched into the sent cookie set
binary send the data string in binary mode
nocache don't cache the resource
revalidate revalidate maybe cached content
timeout a timeout in ms
context a property which will be added to the response object
responseType one of arraybuffer, blob, json or stream
overrideMimeType a MIME type for the request
anonymous don't send cookies with the requests (please see the fetch notes)
fetch (beta) use a fetch instead of a xhr request (at Chrome this causes details.timeout and xhr.onprogress to not work and makes xhr.onreadystatechange receive only readyState 4 events)
user a user name for authentication
password a password
onabort callback to be executed if the request was aborted
onerror callback to be executed if the request ended up with an error
onloadstart callback to be executed on load start, provides access to the stream object if responseType is set to "stream"
onprogress callback to be executed if the request made some progress
onreadystatechange callback to be executed if the request's ready state changed
ontimeout callback to be executed if the request failed due to a timeout
onload
callback to be executed if the request was loaded.
It gets one argument with the following attributes:
Returns an object with the following property:
Note: the synchronous flag at details is not supported
Important: if you want to use this method then please also check the documentation about @connect.
Downloads a given URL to the local disk.
details can have the following attributes:
The download argument of the onerror callback can have the following attributes:error - error reasonnot_enabled - the download feature isn't enabled by the usernot_whitelisted - the requested file extension is not whitelistednot_permitted - the user enabled the download feature, but did not give the downloads permissionnot_supported - the download feature isn't supported by the browser/versionnot_succeeded - the download wasn't started or failed, the details attribute may provide more informationdetails - detail about that errorReturns an object with the following property:abort - function to be called to cancel this download Depending on the download mode GM_info provides a property called downloadMode which is set to one of the following values: native, disabled or browser.
Get a object that is persistent as long as this tab is open.
Save the tab object to reopen it after a page unload.
Get all tab objects as a hash to communicate with other script instances.
Shows a HTML5 Desktop notification and/or highlight the current tab.
details can have the following attributes:
All parameters do exactly the same like their corresponding details property pendant.
Copies data into the clipboard. The parameter 'info' can be an object like "{ type: 'text', mimetype: 'text/plain'}" or just a string expressing the type ("text" or "html").
Get some info about the script and TM. The object might look like this:
Code:
Object+---> script: Object+------> author: ""------>copyright: "2012+, You"------>description: "enter something useful"------>excludes: Array[0]------>homepage: null------>icon: null------>icon64: null------>includes: Array[2]------>lastUpdated: 1338465932430------>matches: Array[2]------>downloadMode: 'browser'------>name: "Local File Test"------>namespace: "http://your.homepage/"------>options: Object+--------->awareOfChrome: true--------->compat_arrayleft: false--------->compat_foreach: false--------->compat_forvarin: false--------->compat_metadata: false--------->compat_prototypes: false--------->compat_uW_gmonkey: false--------->noframes: false--------->override: Object+------------>excludes: false------------>includes: false------------>orig_excludes: Array[0]------------>orig_includes: Array[2]------------>use_excludes: Array[0]------------>use_includes: Array[0]--------->run_at: "document-end"------>position: 1------>resources: Array[0]------>run-at: "document-end"------>system: false------>unwrap: false------>version: "0.1"---> scriptMetaStr: undefined---> scriptSource: "// ==UserScript==\n// @name Local File Test\n ...."---> scriptUpdateURL: undefined---> scriptWillUpdate: false---> scriptHandler: "Tampermonkey"---> isIncognito: false---> isFirstPartyIsolation: false---> version: "4.0.25"
Tampermonkey supports this way of storing meta data. TM tries to automatically detect whether a script needs this compatibility option to be enabled.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。