Userscript Header
@name
@namespace
@version
@author
@description
@homepage, @homepageURL, @website and @source
@icon, @iconURL and @defaulticon
@icon64 and @icon64URL
@updateURL
@downloadURL
@supportURL
@include
@match
@exclude
@require
@resource
@connect
@run-at
@grant
@noframes
@unwrap
@nocompat
Application Programming Interface
unsafeWindow
Subresource Integrity
GM_addStyle(css)(TM4.0+弃用)
GM_deleteValue(name)
GM_listValues()
GM_addValueChangeListener(name, function(name, old_value, new_value, remote) {})
GM_removeValueChangeListener(listener_id)
GM_setValue(name, value)
GM_getValue(name, defaultValue)
GM_log(message)
GM_getResourceText(name)
GM_getResourceURL(name)
GM_registerMenuCommand(name, fn, accessKey)
GM_unregisterMenuCommand(menuCmdId)
GM_openInTab(url, options), GM_openInTab(url, loadInBackground)
GM_xmlhttpRequest(details)
GM_download(details), GM_download(url, name)
GM_getTab(cb)
GM_saveTab(tab)
GM_getTabs(cb)
GM_notification(details, ondone), GM_notification(text, title, image, onclick)
GM_setClipboard(data, info)
GM_info
<><![CDATA[your_text_here]]></>
Userscript Header
@name
脚本的名称
@namespace
该脚本的命名空间
@version
版本号。当脚本未从 userscript.org安装时或 Tampermonkey 检索脚本元数据有问题时,用于更新检查。
@author
作者
@description
简介
@homepage, @homepageURL, @website and @source
作者主页,用于在Tampermonkey选项页面上从脚本名称点击跳转。请注意,如果`@namespace`标记以"http://"开头,此处也要一样。
@icon, @iconURL and @defaulticon
低分辨率图标
@icon64 and @icon64URL
64x64的图标。如果同时定义`@icon`和`@icon64`,Tampermonkey仍可能优先使用`@icon`定义的图标。
@updateURL
检查更新的网址。注意:需要定义@version
@downloadURL
更新下载脚本的网址,如果定义成`none`就不会检查更新。
@supportURL
报告问题的网址
@include
脚本生效地址,每行一个。不支持URL hash(即网址中的#),详情点击https://forum.tampermonkey.net/viewtopic.php?p=3094
示例:
// @include http://tampermonkey.net/*
// @include http://*
// @include https://*
// @include *
@match
约等于@include标签,详情点击http://code.google.com/chrome/extensions/match_patterns.html。
注意:"<all_urls>"语句尚不支持,scheme部分也接受"http*://"。
@exclude
不生效页面,每行一个。优先于`@include`和`@match`
@requir