油猴脚本API 您所在的位置:网站首页 脚本api 油猴脚本API

油猴脚本API

2023-05-29 15:55| 来源: 网络整理| 查看: 265

参考

油猴文档 本地开发调试设置 深入浅出 Greasemonkey 这个类似油猴,但是火狐上的,有pdf可下 跨页面传值的方式 跨页面传值-这个应该是操作storage

补充:设置chrome采用默认打印设置,静默打印不弹框

Userscript Header

用户脚本头,用于放在脚本开头的注释部分,代表了脚本本身的一些信息,如在哪些页面被调用,有哪些权限等

@name

The name of the script. 脚本名称

Internationalization is done by adding an appendix naming the locale. 国际化是通过添加一个命名区域的附录来完成的。(用于展示不同语言的脚本名称,见下面)

Code:

// @name A test // @name:de Ein Test @namespace

The namespace of the script. 脚本的命名空间

@version

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. 脚本版本。用于更新检查,以防不是从userscript.org 或 TM(即 tampermonkey 油猴本身) 安装脚本的用户在检索脚本元数据时遇到问题。

@author

The scripts author. 脚本作者

@description

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 // @description:zh 中文的描述内容 @homepage, @homepageURL, @website and @source

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. 用于设置访问脚本作者主页的链接,位于油猴的控制面板对应脚本的主页项。请注意,如果@namespace标记以“http://”开头,则其内容也将用于此目的。

@icon, @iconURL and @defaulticon

The script icon in low res. 低分辨率的脚本图标。

@icon64 and @icon64URL

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. 此脚本图标为64x64像素。如果这个标签,但是给了 @icon ,@icon 图像将在选项页的某些地方缩放。???

@updateURL

An update URL for the userscript. Note: a @version tag is required to make update checks work. 用户脚本的更新URL。 注意:需要 @version 标记才能进行更新检查。

@downloadURL

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. 定义检测到更新时将从中下载脚本的URL。如果使用值none,则不会执行更新检查。

@supportURL

Defines the URL where the user can report issues and get personal support. 定义用户可以在其中报告问题和获得个人支持的URL。

@include

The pages on that a script should run. Multiple tag instances are allowed. Please note that @include doesn't support the URL hash parameter. You have to match the path without the hash parameter and make use of window.onurlchange

脚本应该运行的页面。允许多个标记实例。 请注意,@include不支持URL散列参数(即URL中带有md5之类的参数,用来检查URL指定的文件是否匹配)。必须匹配不带哈希参数的路径,同时要使用 window.onurlchange(监听url改变的权限,见@grant部分)

Code:

// @include http://www.tampermonkey.net/* // @include http://* // @include https://* // @include /^https:\/\/www\.tampermonkey\.net\/.*$/ // @include * @match

More or less equal to the @include tag. You can get more information here . Note: the '' statement is not yet supported and the scheme part also accepts 'http*😕/'.

Multiple tag instances are allowed.

类似于@include标记。更多信息 注意:尚不支持“”语句,并且方案部分也接受“http*://”。

允许多个标记实例。

@match 和 @include 是有一点区别的 match更严格一点,它对 * 的含义设定了更严格的规则,具体怎么个严格法?鬼知道

@exclude

Exclude URLs even it they are included by @include or @match . Multiple tag instances are allowed.

排除URL,即使它们被@include或@match包含。 允许多个标记实例。

@require

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!

指定在脚本本身开始运行之前就要加载并执行的JavaScript文件。 注意:通过@require加载的脚本及其“use strict”语句可能会影响用户脚本的严格模式!

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. 有关如何确保完整性的更多信息,请查看子资源完整性部分。允许多个标记实例。

@resource

Preloads resources that can by accessed via GM_getResourceURL and GM_getResourceText by the script. 预加载可以通过脚本通过GM_getResourceURL和GM_getResourceText访问的资源。

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. 有关如何确保完整性的更多信息,请查看子资源完整性部分。允许多个标记实例。

@connect

This tag defines the domains (no top-level domains) including subdomains which are allowed to be retrieved by GM_xmlhttpRequest 此tag用于定义域名(不包括顶级域),包括允许GM_xmlhttpRequest检索的子域

Code:

// @connect

can have the following values: 可选值如下

domains like tampermonkey.net (this will also allow all sub-domains) sub-domains i.e. safari.tampermonkey.net self to whitelist the domain the script is currently running at localhost to access the localhost 1.2.3.4 to connect to an IP address *

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. 另外在脚本中添加“@connect *”。这样做,Tampermonkey仍然会询问用户是否允许下一次连接到未提及的域,但也会 提供一个“始终允许所有域”按钮。如果用户单击此按钮,则将自动允许所有未来的请求。

Users can also whitelist all requests by adding '*' to the user domain whitelist at the script settings tab. 用户还可以通过将“*”添加到“脚本设置”选项卡上的“用户域白名单”来将所有请求列入白名单。

Notes:

both, the initial and the final URL will be checked! for backward compatibility to Scriptish @domain tags are interpreted as well.

注意: 初始和最终的网址都将被检查! 为了向后兼容,@domain标记也一如既往地进行了解析。

Multiple tag instances are allowed. 允许多个标记实例。

@run-at

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.

定义注入脚本的时刻。与其他脚本处理程序相反,@run at 定义了脚本想要运行的第一个可能时刻。这意味着可能会发生这样的情况:使用@require标记的脚本可能会在文档已经加载之后执行,因为获取所需的脚本需要很长时间。无论如何,在给定的注入时刻之后发生的所有 DOMNodeInserted 和 DOMContentLoaded 事件都会被缓存,并在注入脚本时传递给脚本。

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. 如果body元素存在,脚本将被注入。

Code:

// @run-at document-end

The script will be injected when or after the DOMContentLoaded event was dispatched. 在调度DOMContentLoaded事件时或之后将注入脚本。

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. 在调度DOMContentLoaded事件之后,将注入脚本。如果没有给出@run at标记,这是默认值。

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.

如果在浏览器上下文菜单中单击脚本(仅限于基于Chrome的桌面浏览器),则会注入脚本。 注意:如果使用此值,所有@include和@exclude语句都将被忽略,但这可能会在将来更改。

@grant

@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. @grant (授予)用于白名单 GM_* 函数、unsafeWindow 对象和一些强大的窗口函数。如果没有给@grant标记,TM 将猜测脚本需要什么。

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:

由于关闭和聚焦选项卡(浏览器页面)是一项强大的功能,因此需要将其添加到@grant语句中。 如果脚本在单页应用程序上运行,那么它可以使用 window.onurlchange 来侦听URL更改:

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. 如果@grant后跟着“none”,那么沙盒将被禁用,脚本将直接在页面上下文中运行。在这种模式下,没有 GM_* 函数,但是GM_info属性可用。

Code:

// @grant none @antifeature

This tag allows script developers to disclose whether they monetize their scripts. It is for example required by GreasyFork. 这个标签允许脚本开发人员披露他们是否将脚本货币化(通过脚本盈利)。例如,GreasyFork 脚本网站 需要这个标签。

Syntax:

can have the following values:

ads 广告 tracking 跟踪 miner 矿工

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. 国际化是通过添加一个命名语言环境的附录来完成的(见前文说明)。

@noframes

This tag makes the script running on the main pages, but not at iframes. 此标记使脚本在主页上运行,但不在iframe(即一个页面内嵌套的页面,详见html内容)上运行。

@unwrap

This tag is ignored because, it is not needed at Google Chrome/Chromium. 这个标签被忽略了,因为Google Chrome/Chromium不需要它。

@nocompat

At the moment TM tries to detect whether a script was written in knowledge of Google Chrome/Chromium by looking for the @match tag, but not every script uses it. That's why TM supports this tag to disable all optimizations that might be necessary to run scripts written for Firefox/Greasemonkey. To keep this tag extensible you can to add the browser name that can be handled by the script.

目前,TM通过查找@match标记来检测脚本是否是在Google Chrome/Chromium的规范下编写的,但并不是每个脚本都使用它。这就是为什么TM支持用这个标签来禁用所有的优化,因为为了能够运行那些专为 Firefox/Greasemonkey 编写的脚本这么做可能是必须的。如果要保持此标记的可扩展性,可以通过添加可由脚本处理的浏览器名称来实现。

Code:

// @nocompat Chrome Application Programming Interface 油猴应用程序接口(API) unsafeWindow

The unsafeWindow object provides full access to the pages javascript functions and variables. unsafeWindow对象提供对页面的javascript函数和变量的完全访问。

Subresource Integrity

子资源完整性

The hash component of the URL of @resource and @require tags can be used for this purpose. @resource和@require标记的URL的哈希组件可用于此目的。

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...

TM supports MD5 hashes as a fallback natively, all other (SHA-1, SHA-256, 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.

TM 支持MD5哈希作为后备默认,所有其他哈希(SHA-1、SHA-256、SHA-384和SHA-512)依赖于window.crypto. 如果给出了多个散列(用逗号或分号分隔),则TM将使用当前支持的最后一个散列。如果外部资源的内容与所选哈希不匹配,则资源不会传递到用户脚本。所有哈希都需要以十六进制或Base64格式编码。

GM_addStyle(css)

Adds the given style to the document and returns the injected style element. 将给定的样式添加到文档并返回注入的样式元素。

GM_addElement(tag_name, attributes), GM_addElement(parent_node, tag_name, attributes)

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. 创建一个由“tag_name”指定的HTML元素,应用所有给定的“属性”,并返回注入的HTML元素。如果给定了“父节点”,则它将附加到该节点否则附加到文档头或文档体。

For suitable 'attributes', please consult the appropriate documentation. For example: 合适的“属性”,请参阅相应的文档。例如:

script tag img tag style tag

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. 注意:此功能是实验性的,API可能会更改。

GM_deleteValue(name)

Deletes 'name' from storage. 从存储器中删除指定name(变量?)。

GM_listValues()

List all names of the storage. 列出存储的所有name(变量?)。

GM_addValueChangeListener(name, function(name, old_value, new_value, remote) {})

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.

将一个变动监听器添加到存储并返回监听器ID。 “name”是被监测变量的名称。 回调函数的“remote”参数显示此变量是从另一个选项卡的实例修改的(true),还是在此脚本实例中修改的(false)。 因此,浏览器不同选项卡的脚本可以使用此功能相互通信。

GM_removeValueChangeListener(listener_id)

Removes a change listener by its ID. 删除指定ID的变动侦听器。

GM_setValue(name, value)

Set the value of 'name' to the storage. 设置指定变量的值

GM_getValue(name, defaultValue)

Get the value of 'name' from storage. 获取指定变量的值

GM_log(message)

Log a message to the console. 写日志到控制台

GM_getResourceText(name)

Get the content of a predefined @resource tag at the script header. 获取脚本开头预定义的@resource标签的内容。

GM_getResourceURL(name)

Get the base64 encoded URI of a predefined @resource tag at the script header. 获取脚本开头处预定义的@resource标记的base64编码URI。

GM_registerMenuCommand(name, fn, accessKey)

Register a menu to be displayed at the Tampermonkey menu at pages where this script runs and returns a menu command ID. 注册一个菜单显示在运行此脚本的页面上的Tampermonkey菜单上,并返回菜单命令ID。

GM_unregisterMenuCommand(menuCmdId)

Unregister a menu command that was previously registered by GM_registerMenuCommand with the given menu command ID. 取消注册上面注册的菜单命令,通过上面得到的命令ID

GM_openInTab(url, options), GM_openInTab(url, loadInBackground)

Open a new tab with this url. The options object can have the following properties: 使用此url打开新选项卡。options对象可以具有以下属性:

active decides whether the new tab should be focused, 决定是否聚焦新选项卡 insert that inserts the new tab after the current one, 在当前选项卡之后插入新选项卡 setParent makes the browser re-focus the current tab on close and 使浏览器重新聚焦当前选项卡 incognito makes the tab being opened inside a incognito mode/private mode window. 使选项卡在匿名模式/专用模式窗口中打开

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.

否则,将只是打开新选项卡。loadInBackground与active的含义相反,添加它是为了实现Greasemonkey 3.x(见前,一种专为火狐浏览器编写的脚本)兼容性。如果既不提供active也不提供loadInBackground,则选项卡将不会被聚焦。此函数返回一个对象,其中包含close函数、onclose侦听器和一个名为closed的标志。

GM_xmlhttpRequest(details)

Make an xmlHttpRequest. 进行xmlHttp请求

Property of details: details属性的详情

method one of GET, HEAD, POST 请求方法类型 url the destination URL 目的url headers ie. user-agent, referer, ... (some special headers are not supported by Safari and Android browsers) 头部:例如,用户代理、推荐人。。。(Safari和Android浏览器不支持某些特殊标题) data some string to send via a POST request 通过POST请求发送的字符串 cookie a cookie to be patched into the sent cookie set 要补充到已发送cookie集中的cookie 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 响应类型:arraybuffer、blob、json之一 overrideMimeType a MIME type for the request 重写MIME类型:一种MIME类型for请求 anonymous don't send cookies with the requests (please see the fetch notes) 匿名的:不要随请求一起发送cookie(请参阅获取说明) fetch (beta) use a fetch instead of a xhr request (at Chrome this causes xhr.abort, details.timeout and xhr.onprogress to not work and makes xhr.onreadystatechange receive only readyState 4 events) 取回、提取:(beta版)使用fetch请求而不是xhr请求 (对于Chrome浏览器,以下情况将导致xhr.中止, 详细信息:超时、xhr.onprogress 不工作,并且使得 xhr.onreadystatechange 仅接收 readyState 4 事件) username a username 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 if the request started to load 请求开始加载时执行的回调 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: 通过以下属性可以获取对应参数 finalUrl - the final URL after all redirects from where the data was loaded 最终Url:所有重定向之后,最终加载数据时的最终Url readyState - the ready state 就绪状态 status - the request status 请求状态 statusText - the request status text 文本形式的就绪状态 responseHeaders - the request response headers 请求的响应头 response - the response data as object if details.responseType was set 如果details.responseType 被设置,则响应数据为对象类型 responseXML - the response data as XML document 响应数据为XML文档 responseText - the response data as plain string 响应数据为纯字符串

Returns an object with the following property: xmlHttp请求返回具有以下属性的对象:

abort - function to be called to cancel this request 取消请求

Note: the synchronous flag at details is not supported 注意:details 不支持 同步 标志

Important: if you want to use this method then please also check the documentation about @connect. 重要提示:如果您想使用此方法,请同时查看有关@connect的文档。

GM_download(details), GM_download(url, name)

Downloads a given URL to the local disk. 将给定的URL下载到本地磁盘。

details can have the following attributes: details 可以具有以下属性:

url - the URL from where the data should be downloaded (required) 下载数据的URL(必需) name - the filename - for security reasons the file extension needs to be whitelisted at Tampermonkey's options page (required) 文件名-出于安全原因,文件扩展名需要在Tampermonkey的选项页上列出(必需) headers - see GM_xmlhttpRequest for more details 有关详细信息,请参阅GM\u xmlhttpRequest saveAs - boolean value, show a saveAs dialog 布尔值,显示另存为对话框 onerror callback to be executed if this download ended up with an error 下载发生错误时的回调 onload callback to be executed if this download finished 下载完成时的回调 onprogress callback to be executed if this download made some progress 下载取得一些进度时的回调 ontimeout callback to be executed if this download failed due to a timeout 下载超时失败时的回调

The download argument of the onerror callback can have the following attributes: 下载参数onerror 回调可以有以下属性

error - error reason 错误原因 not_enabled - the download feature isn't enabled by the user 用户未启用下载功能 not_whitelisted - the requested file extension is not whitelisted 请求的文件扩展名未列入白名单 not_permitted - the user enabled the download feature, but did not give the downloads permission 用户启用了下载功能,但未授予下载权限 not_supported - the download feature isn't supported by the browser/version 浏览器/版本不支持下载功能 not_succeeded - the download wasn't started or failed, the details attribute may provide more information 下载未启动或失败,details 属性可以提供更多信息 details - detail about that error 错误详情

Returns 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. 根据下载模式,GM_info 提供一个名为 downloadMode 的属性,该属性为以下值之一:native、disabled 或 browser。

GM_getTab(callback)

Get a object that is persistent as long as this tab is open. 获取一个在选项卡打开期间能一直存在的(选项卡?)对象。

GM_saveTab(tab)

Save the tab object to reopen it after a page unload. 保存选项卡对象以在页面卸载后重新打开它

GM_getTabs(callback)

Get all tab objects as a hash to communicate with other script instances. 将所有选项卡对象作为散列获取,以便与其他脚本实例通信。

GM_notification(details, ondone), GM_notification(text, title, image, onclick)

Shows a HTML5 Desktop notification and/or highlight the current tab. 显示HTML5桌面通知和/或突出显示当前选项卡。

details can have the following attributes: details 可以具有以下属性:

text - the text of the notification (required unless highlight is set) 通知的文本(除非设置了highlight值,否则必须输入) title - the notificaton title 通知的标题 image - the image 图片 highlight - a boolean flag whether to highlight the tab that sends the notfication (required unless text is set) 一个布尔标志,是否突出显示发送通知的选项卡(除非设置了text值,否则为必需) silent - a boolean flag whether to not play a sound 是否播放声音 timeout - the time after that the notification will be hidden (0 = disabled) 多长时间后通知隐藏(0表示不隐藏) ondone - called when the notification is closed (no matter if this was triggered by a timeout or a click) or the tab was highlighted 当通知关闭(无论这是由超时或单击触发)或选项卡高亮显示之后的调用 onclick - called in case the user clicks the notification 用户点击通知时的回调

All parameters do exactly the same like their corresponding details property pendant. 所有参数的作用与其对应的details属性完全相同。

GM_setClipboard(data, info)

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"). 将数据复制到剪贴板。参数 info 可以是一个类似于“{type:'text',mimetype:'text/plain'}”的对象,也可以只是一个表示(一种)类型的字符串("text"或"html")。

GM_info

Get some info about the script and TM. The object might look like this: 获取一些关于脚本和TM的信息。对象可能如下所示:

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. Tampermonkey支持这种存储元数据的方式。TM尝试自动检测脚本是否需要启用此兼容性选项。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有