Tampermonkey Chinese Documents

User script title

@name

Name of the script.

@namespace

Namespace script.

@version

Script version. This is a problem for updating checking to prevent the script from userscript.org not installed, the script retrieves metadata or TM.

@author

Script author.

@description

A brief description of important.

@homepage、@homepageURL、@website和@source

Use the options in the author's home page links from the script name to a given page. Please note that if @namespace tab to: Starts "http //", the contents of which will be used for this.

@icon、@iconURL和@defaulticon

Script icon at low resolution.

@ Icon64 and @ icon64URL

This script icon is 64x64 pixels. If this tag, but given @icon image @icon certain position on the page scaling options.

@updateURL

Update user script URL.
Note: You need @version check mark for the update to work properly.

@downloadURL

Define when an update is detected URL from which to download the script. If you use a value of none, will not perform the update check.

@supportURL

Define user can report problems and get personal support of the URL.

@include

The script should be run page. Tag allows multiple instances.
Please note, @ include the hash does not support URL parameters. Please visit this forum thread for more information: Click .

Code:

// @include http://*  
// @include https://*  
// @include *  

@match

It is equal to or less @include tag. You can here to get more information.
Note: does not yet support '<all_urls>' statement, part of the program also accepts 'http *: //'.
Allowing a plurality of labels.

@exclude

Exclude URL, even if they are included in @include or @match.
Tag allows multiple instances.

@require

Pointing loaded and executed before the script itself runs JavaScript file. Note: By @require loaded script and its "use strict" statement may affect userscript of 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...  

For more information on how to ensure the integrity, check the integrity of the child resource section. Tag allows multiple instances.

@resource

By preloading script resource that can be accessed by GM getResourceURL and 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...  

For more information on how to ensure the integrity, check the integrity of the child resource section. Tag allows multiple instances.

@connect

This tag domain (no top-level domain), comprising allows GM_xmlhttpRequest retrieved subdomain

Code:

// @connect <value>  

<value>You can have the following values:

  • Like tampermonkey.net this domain (which will also allow all subdomains)
  • Subdomains namely safari.tampermonkey.net
  • The script is currently running a domain whitelist
  • localhost Access to the local host
  • A connection to the IP address 1.2.3.4
  • *

If you can not declare all domains userscript may be connected to, it is best to do the following:
All known domain scripting statements that may be connected or at least all the usual domain . In this way, most users can avoid the confirmation dialog box. In addition, the "@connect" added to the script. By doing so, Tampermonkey still will ask the user whether to allow field next connection is not mentioned, but also provides an "always allow all domains" button .
If the user clicks the button, it will automatically allow all future requests. Users can also set the script tab of the "*" to the user domain whitelist to all requests whitelist.

note:

  • The initial URL and final URL will be checked!
  • For the script @domain backward compatibility markers, but also he explained.

Tag allows multiple instances.

@run-at

Custom scripts to be injected at the moment. In contrast with other script handler, @ run-at the first possible moment defined script you want to run. This means that such a situation might occur, the script uses @require mark may be executed after the document has been loaded, because to obtain the required script takes a long time. In any case, all domnodeinsert and DOMContentLoaded events are cached occur after injection given moment, and delivered to the script when injected into the script.

Code:

// @run-at document-start  

The script injection as soon as possible.

Code:

// @run-at document-body  

If the text element is present, it will inject script.

Code:

// @run-at document-end  

When scheduling content DOM load event or after the injection of the script.

Code:

// @run-at document-idle  

After scheduling content DOM load event, will be injected into the script. If not given @run mark, which is the default.

Code:

// @run-at context-menu  

If you click on a script in the browser context menu (on the desktop chrome browser-based only), the script will be injected. Note: If you use this value, all @include and @exclude statements are ignored, but this may change in the future.

@grant

@grant for GM_ * function, unsafeWindow objects, and some powerful window function whitelist. If no @grant label, TM would guess demand script.

Code:

// @grant GM_setValue  
// @grant GM_getValue  
// @grant GM_setClipboard  
// @grant unsafeWindow  
// @grant window.close  
// @grant window.focus  

Due to the closure and focus tab is a powerful feature, and therefore need to add it to @grant statement.

If @grant followed behind "none", then the sandbox will be disabled, the script will run directly in the page context. In this mode, no GM * function, but GM attribute information is available.

Code:

// @grant none

@noframes

This marks the script runs on the home page, but not running on iframe.

@unwrap

This tag is ignored because it is not required in the Google Chrome / Chromium.

@nocompat

Currently, TM @match trying to find markers to detect whether the Google Chrome scripting Chromium /, but not every script that uses it. That is why TM supports this tab to disable all optimizations may need to run the scripts for Firefox / Greasemonkey written. To keep this mark scalability, you can add the name of the browser handled by the script.

Code:

// @nocompat Chrome

Guess you like

Origin www.cnblogs.com/grubber/p/12560522.html