It is currently 24.04.14 02:39:12

All times are UTC + 1 hour [ DST ]




 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: API
PostPosted: 04.05.11 10:00:35 
Site Admin
User avatar

Joined: 20.01.06 02:16:15
Posts: 1260
unsafeWindow

The unsafeWindow object provides full access to the pages javascript functions and variables.

DOMAttrModified

Chrome/Chromium does not have native DOMAttrModified support, but in TM statements like
var foo = document.getElementById('whatever');
foo.addEventListener("DOMAttrModified", function (e) {console.log(e); }), false);
are working as usual for any attribute change of "foo".
Event handlers that catch bubbled events like this:
document.addEventListener("DOMAttrModified", function (e) {console.log(e); }), false);
are working too, but will only be notified of changes of objects that are "registered" for DOMAttrModified like the element "foo" is.


wrappedJSObject

Although this is not needed in Chrome/Chromium some scripts need that object to be part of HTML elements to run successfully. That's why TM adds this property to every HTMLElement to return the (never wrapped) element.

GM_addStyle(css)

Adds the given style to the document.

GM_deleteValue(name)

Deletes 'name' from storage.

GM_listValues()

List all names of the storage.

GM_addValueChangeListener(name, function(name, old_value, new_value, remote) {}) needs build nr. 2602 or greater

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.


GM_removeValueChangeListener(listener_id) needs build nr. 2602 or greater

Removes a change listener by its 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.

GM_getResourceURL(name)

Get the base64 encoded URI of a predefined @resource tag at the script header.

GM_registerMenuCommand(name, fn)

Register a menu to be displayed at the Tampermonkey menu at pages where this script runs.

GM_openInTab(url, options)

Open a new tab with this url. The options object can have two properties: 'active' decides whether the new tab should be focused and 'insert' that inserts the new tab after the current one. Otherwise the new tab is just appended.

GM_xmlhttpRequest(details)

Make an xmlhttpRequest. Supports:
- cross domain requests
- headers (user-agent, referer, ...) needs build nr. 2656 or greater
- Note: the synchronous flag at the details is not supported


GM_getTab(cb)

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(cb)

Get all tab objects in an array to communicate with other scrips instances.

GM_notification(msg, title, callback, delay)

Shows a notification that will be hidden after delay ms (0 = disabled) and the callback is called in case the user clicks the notification.

GM_getVersion()

Returns the Tampermonkey version string.

GM_installScript(url, callback)

Install a userscript to Tampermonkey. The callback gets an object like "{ found: true, installed: true }" that shows whether the script was found and the user installed it.

GM_info

Get some info about the script and TM. The object might look like this:
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]
------>name: "Local File Test"
------>namespace: "http://use.i.E.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==↵// @name       Local File Test↵// ....↵"
---> scriptUpdateURL: undefined
---> scriptWillUpdate: false
---> scriptHandler: "Tampermonkey"
---> version: "2.4.2716"


<><![CDATA[blubber]]></>

Tampermonkey supports this way of storing meta data. TM tries to automatically detect whether a script needs this option to be enabled.

for each (var k in arr)

Tampermonkey replaces "for each" statements by chrome compatible code. TM tries to automatically detect whether a script needs this option to be enabled.



_________________
Image ImageIf you like what I'm doing, please consider a donation here. Image
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: