Skip to content
🤔prompts chat🧠
🔍
question:do script for firemonkey in firefox to delete all possible and impossible cookies and caches data through timer in 10 sec.: // ==UserScript== // @name // @match :///* // @version 1.0 // ==/UserScript== Creating a UserScript to delete all possible and impossible cookies and cached data through a timer would involve using the document.cookie property and the browser’s cache APIs. However, certain limitations must be kept in mind: 1. UserScripts generally run in the content script environment and do not have the privileges to clear cookies or cache directly for security reasons. 2. Clearing cookies programmatically through JavaScript in a UserScript is typically limited to cookies that are set with HttpOnly set to false and for the domain that the script is running on. 3. Clearing cache programmatically is usually not accessible through a UserScript due to browser security restrictions. Given these limitations, the following script can attempt to delete cookies accessible to the UserScript but will not be able to clear the browser cache or cookies with the HttpOnly flag. // ==UserScript== // @name Auto Clear Cookies // @namespace http://tampermonkey.net/ // @match :///* // @version 1.0 // @grant none // ==/UserScript== (function() { ‘use strict’; function deleteCookies() { // Get all cookies for the current domain var cookies = document.cookie.split(“;”); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(“=”); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; // Delete the cookie by setting the expiration date to the past document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/”; } } // Set a timer to delete cookies every 10 seconds setInterval(deleteCookies, 10000); })(); However, I must reiterate that this script will not effectively clear all cookies, especially those that are HttpOnly or belong to different domains or paths inaccessible to the script. The script also will not clear cache due to the security limitations mentioned above. If you want to fully clear cookies and cache, you typically need to do so through the browser’s built-in functionality or an extension with the appropriate permissions. If running in Firefox through an add-on or a privileged environment like a browser extension, one would use the WebExtensions API to clear cookies and cache, specifically the browsingData API which requires additional permissions and cannot be accessed through a UserScript in the web page context. “:///*” unsupported scheme it tells. I apologize for the confusion. In UserScripts, particularly ones managed by userscript managers like Tampermonkey or Greasemonkey, the @match directive needs to specify supported URL schemes. The * character is a wildcard for the hostname, but it cannot be used as a wildcard for the scheme (i.e., http or https). In your UserScript, the @match directive should look something like this to match all HTTP and HTTPS pages: // @match http:/// // @match https:/// The corrected UserScript with an updated match directive would be: // ==UserScript== // @name Auto Clear Cookies // @namespace http://tampermonkey.net/ // @match http:/// // @match https:/// // @version 1.0 // @grant none // ==/UserScript== (function() { ‘use strict’; function deleteCookies() { var cookies = document.cookie.split(“;”); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(“=”); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/”; } } setInterval(deleteCookies, 10000); })(); However, remember that this will only attempt to delete cookies that are not HttpOnly and are accessible to JavaScript on the current domain. It will not work for cookies set by other domains (such as third-party cookies) or cookies designated as HttpOnly. The UserScript will also not clear the cache data because that requires privileged access to browser functions that UserScripts do not typically have. For clearing cache and all types of cookies, you will need to use the browser’s built-in functions (such as clearing cache from the browser settings) or an extension with the necessary permissions for accessing the browsingData API. missing host If you’re receiving an error about a missing host with the @match directive when creating a UserScript, it is most likely due to an incorrect or unsupported pattern. In UserScripts, the @match directive needs to specify patterns that conform to the match pattern system. A correct @match pattern that includes both HTTP and HTTPS for all websites and all paths looks like this: // @match :/// The corrected full UserScript example for clearing cookies (although limited as explained previously) every 10 seconds would be: // ==UserScript== // @name Auto Clear Cookies // @namespace http://tampermonkey.net/ // @version 1.0 // @description Clear accessible cookies every 10 seconds. // @match :/// // @grant none // ==/UserScript== (function() { ‘use strict’; // Function to delete accessible cookies function deleteCookies() { var cookies = document.cookie.split(“;”); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(“=”); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie.trim(); document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/”; } } // Set an interval to periodically delete cookies setInterval(deleteCookies, 10000); })(); To install this UserScript, you need to have a userscript extension like Tampermonkey or Greasemonkey installed in your Firefox. Once the extension is installed, you can create a new userscript and paste the above code into the editor, then save it. The script will then run on all pages that you visit, but keep the following in mind: 1. The UserScript will only clear cookies that are set without the HttpOnly flag and are accessible to JavaScript at the domain the script is running on. 2. The UserScript cannot clear browsing cache data due to the security context it operates within. 3. Only some cookies will be affected, specifically those that pertain to the current page’s domain. To clear all cookies and cache from all origins, you would typically need to use your browser’s native settings or develop a browser extension with appropriate permissions to access the browsingData API or similar. “// @match http:/// // @match https:///”. missing path The @match directive in a userscript is used to specify which web pages your script should run on. The “missing path” error suggests that the pattern you have is incomplete. For the @match directive, you need to provide a complete pattern that includes the scheme (e.g., http:// or https://), the host, and the path. The wildcard * can be used to match any string of characters, and a path is required after the host. If you want to match all paths on any site, you need to include a * after the host pattern. Here’s the correct way to write @match directives to include all secure (https) and insecure (http) web pages: // @match http:/// // @match https:/// The correct full script incorporating these @match directives would look like this: // ==UserScript== // @name Auto Clear Cookies // @namespace http://tampermonkey.net/ // @version 1.0 // @description Try to clear cookies every 10 seconds. // @match http:/// // @match https:/// // @grant none // ==/UserScript== (function() { ‘use strict’; function deleteCookies() { var cookies = document.cookie.split(“;”); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(“=”); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/”; } } setInterval(deleteCookies, 10000); })(); Adding this script to a userscript manager like Tampermonkey or Greasemonkey should no longer result in a “missing path” error. Remember, though, that the script’s ability to delete cookies is limited as per the previous discussion: it cannot delete cookies that have the HttpOnly flag set or cookies not accessible to the domain where the script runs. Additionally, this script cannot clear the cache because script environments like Tampermonkey do not allow that level of access due to security considerations. maybe all https and http sies within .com domain? how? If you want to target all websites within the .com top-level domain (TLD), you would need to adjust your @match directive to use a wildcard for the protocol and subdomains, while specifying the .com TLD for the domain part. Here’s how you could construct your @match directive to apply the userscript to all .com domains: // @match http://.com/ // @match https://.com/ This pattern will run the userscript on any http:// or https:// URL that ends with .com and includes any characters (including subdomains) before .com. Here is the complete userscript with the specified match patterns: // ==UserScript== // @name Auto Clear Cookies for .com Domains // @namespace http://tampermonkey.net/ // @version 1.0 // @description Try to clear cookies for .com domains every 10 seconds. // @match http://.com/ // @match https://.com/ // @grant none // ==/UserScript== (function() { ‘use strict’; function deleteCookies() { var cookies = document.cookie.split(“;”); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(“=”); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie.trim(); document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/”; document.cookie = name + “=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.com”; } } setInterval(deleteCookies, 10000); })(); Remember that this script will only attempt to delete cookies accessible from JavaScript for the current domain (and subdomain) that the script is running on. It will not clear cookies that are set with the HttpOnly attribute or cookies from third-party domains. Additionally, the script cannot clear the browser’s cache as discussed in previous answers. To clear all cookies and cache, manual intervention through the browser’s settings menu or the development of a browser extension with the necessary permissions would be required. Stack Overflow About Products For Teams Home Questions Tags Users Companies Labs Discussions New Collectives Explore Collectives Teams Stack Overflow for Teams – Start collaborating and sharing organizational knowledge. Include all pages in tampermonkey(userscript) Asked 10 years, 11 months ago Modified 1 year, 4 months ago Viewed 59k times 72 I have to include all sites in tampermonkey…this is the script that i have to run // ==UserScript== // @name Phishing Blockz // @namespace http://use.i.E.your.homepage/ // @version 0.1 // @description Phishing block based on hyperlinks // @match http:/// // @run-at document-end var req = new XMLHttpRequest(); req.open(‘GET’, document.location, false); req.send(null); var headers = req.status; var locheader=req.getResponseHeader(“Location”); alert(headers); alert(locheader); Have I done something wrong.please help me to run this userscript in all pages in chrome userscriptstampermonkey Share Improve this question Follow edited Mar 18, 2013 at 12:08 asked Mar 18, 2013 at 11:11 user1972757’s user avatar user1972757 73111 gold badge55 silver badges66 bronze badges At least show your script! The URL “trimming” is just a display choice, it is not the problem. – Brock Adams Mar 18, 2013 at 11:33 Add a comment 5 Answers Sorted by: 97 // @match http:/// will only match addresses starting with http://… but not https://… for example. Use the following to include all addresses if that’s what you really require (including local pages you may have saved on your hard-drive!)… // @match :/// Note: The method below also works at the time of writing by virtue of a potential bug or undocumented feature in TM2.12 (so could well be subject to change in future versions!!): // @match Share Improve this answer Follow edited Apr 17, 2013 at 13:10 answered Apr 2, 2013 at 21:30 Richard Plester’s user avatar Richard Plester 1,16866 silver badges1111 bronze badges 5 @match * is not a valid pattern. See the doc page and there can be more than one @match line. The OP’s metadata block is corrupt and the OP appears to have abandoned this question. – Brock Adams Apr 17, 2013 at 1:09 Shame on OP if has abandoned, though it’s still a useful QA. Would the generally correct syntax be // @match /// ? For the record I have scripts with match * working under TamperMonkey 2.12! – Richard Plester Apr 17, 2013 at 8:42 Close, you need the colon. See the doc. That’s interesting about * in Tampermonkey. I’m going off the Chrome rules – which are supposed to be the master for @match in both Greasemonkey and Tampermonkey. I wonder if Tampermonkey works despite the error – while Chrome does not. I’ll test this at some point. – Brock Adams Apr 17, 2013 at 8:56 2 Okay tested it myself and * works while <all_urls> does not! There is no error in Tampermonkey, even in verbose mode, for either one. This is all a bug, AFAIC, and it’s not consistent with Chrome nor Greasemonkey. Still, your answer is more correct than I thought. +1. – Brock Adams Apr 17, 2013 at 12:03 1 Tampermonkey no longer supports '", so use the more appropriate suggestions shown here now… – Kevin Dec 3, 2018 at 6:52 Show 3 more comments 18 // @match :/// This should find all URLs. Using TamperMonkey/GreaseMonkey // ==UserScript== // @name Match Every Site // @namespace http://tampermonkey.net/ // @version 1.1 // @description I will pop up on every site!! // @author You // @match :/// // @grant none // ==/UserScript== alert(“I am working!”) This might be useful for browser-extensions on some pages: WebExtensions Match Patterns Mozilla Documentation Match Patterns Google Documentation So accordingly: :///* matches all HTTP, HTTPS, and WebSocket URLs. Share Improve this answer Follow edited Sep 4, 2019 at 21:52 answered Jul 16, 2018 at 11:37 Joe’s user avatar Joe 94933 gold badges1515 silver badges3838 bronze badges not working, scheme has to be a text : // @match https:/// // @match http:/// – Nicolas Thery Nov 26, 2022 at 9:40 Add a comment 8 Doing @include instead of @match works quite nicely // ==UserScript== // @name Phishing Blockz // @namespace http://use.i.E.your.homepage/ // @version 0.1 // @description Phishing block based on hyperlinks // @include // @run-at document-end this works on all websites across the web (tested in TamperMonkey) Share Improve this answer Follow answered Feb 18, 2020 at 21:55 əkaunt’s user avatar əkaunt 10911 silver badge33 bronze badges looks deprecated – Nicolas Thery Nov 26, 2022 at 9:39 Add a comment 5 The real answer would be to have: // @match https:/// // @match http:/// Share Improve this answer Follow edited Mar 5, 2020 at 16:48 Adrian Mole’s user avatar Adrian Mole 51.1k181181 gold badges5353 silver badges8686 bronze badges answered Mar 5, 2020 at 16:12 FireyChicken’s user avatar FireyChicken 8411 silver badge66 bronze badges 1 Latest documentation from tampermonkey.net/documentation.php#_match says that it is possible to simple include 'http://'. It does widen the scope, but I think it is highly unlikely there are other protocols that start with http and are not http/https. – powersource97 Jul 30, 2020 at 4:23 Please upvote this one as there is obsolete answer in any others – Nicolas Thery Nov 26, 2022 at 9:40 Add a comment 0 For me, using // @match https:/// // @match http:/// DOES NOT work. Rather, I have to use @include for tampermonkey to load scripts on all pages in my device, // @include https:/// // @include http:/// FYI: I am using tampermonkey in Fennec v105.1(Firefox android version in F-droid) running in android 10 Share Improve this answer Follow answered Oct 1, 2022 at 1:56 justpeanuts’s user avatar justpeanuts 1922 bronze badges Add a comment Your Answer By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy. Not the answer you’re looking for? Browse other questions tagged userscriptstampermonkey or ask your own question. The Overflow Blog Down the rabbit hole in the Stack Exchange network Even LLMs need education—quality data makes LLMs overperform Featured on Meta Upcoming privacy updates: removal of the Activity data section and Google… Changing how community leadership works on Stack Exchange: a proposal and… Temporary policy: Generative AI (e.g., ChatGPT) is banned 2024 Moderator Election Q&A – Question Collection Related 2 In a Greasemonkey script, how can I target a page by its elements? 3 tampermonkey script stops working if I change the page 3 How to include Local htm pages in a Tampermonkey script? 26 Tampermonkey script run before page load 3 Tampermonkey - Match default start page 1 Userscript, that requires page’s javascript, runs in JS console but not in Tampermonkey 1 How to set a userscript to run on an array of websites? 1 Matching just the root/home page in Tampermonkey / Greasemonkey? 1 How can i load an external script on a webpage using tampermonkey? 2 tampermonkey script run accross multiple pages Hot Network Questions MPL license: Can I completely lose grants? Inductor as insulator? How to define (not reproject) a CRS of a shapefile in QGIS? Has this “everything category” been defined before? Every matrix is a product of two symmetric matrices more hot questions Question feed Stack Overflow Questions Help Products Teams Advertising Collectives Talent Company About Press Work Here Legal Privacy Policy Terms of Service Contact Us Cookie Settings Cookie Policy Stack Exchange Network Technology Culture & recreation Life & arts Science Professional Business API Data Blog Facebook Twitter LinkedIn Instagram Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2024.2.26.5346 It appears you have copied content from Stack Overflow that discusses how to use @match and @include directives in userscripts for Tampermonkey. To clarify, here is how you can write a userscript that matches all pages in the .com domain (for both http and https schemes): // ==UserScript== // @name Auto Clear Cookies for .com Domains // @namespace http://tampermonkey.net/ // @version 1.0 // @description Try to clear cookies for .com domains every 10 seconds. // @match http://.com/ // @match https://.com/ // @grant none // ==/UserScript== (function() { ‘use strict’; // This function will attempt to delete all cookies accessible // to JavaScript for a given .com domain and path function deleteCookies() { var cookies = document.cookie.split(‘;’); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf(‘=’); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie.trim(); // Deleting cookie for the domain document.cookie = name + ‘=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/’; // Attempting to delete cookies for the higher-level domain might not work due to security restrictions document.cookie = name + ‘=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.com’; } } // Set a timer to delete cookies every 10 seconds setInterval(deleteCookies, 10000); })(); Remember that this script can only delete cookies that are not HttpOnly and can only affect cookies that the page’s JavaScript has access to. Also, browsers pose restrictions on setting cookies for top-level domains directly, like .com, for security reasons. Please keep in mind that due to browsers’ SameSite and cross-domain policy, this script may not always succeed in deleting cookies even within the .com domain, nor will it clear the cache. To use the script: 1. Ensure you have the Tampermonkey extension installed in your browser. 2. Go to the Tampermonkey Dashboard. 3. Click on the “Create a new script” button. 4. Copy and paste the userscript provided above into the script editor. 5. Save the script. Now the userscript will run on every page you load that ends with .com. “// @include ASTERIX” this works on all websites across the web (tested in TamperMonkey) The @include directive in a userscript allows you to specify which web pages the script should run on. If you’re looking to create a userscript that will run on all websites across the web, you would traditionally use the * wildcard in the @include value to match any URL. However, it seems like there might be a misunderstanding from the text you pasted. Using a single asterisk (*) won’t be interpreted correctly as a wildcard for the scheme, host, and path in a URL. Instead, the correct way to match all URLs using @include is to use a specific wildcard pattern: // @include :/// This pattern will match any protocol (http or https), any subdomain, domain, and TLD, with any path. Alternatively, you can use the @match directive which uses specific match patterns, and is generally preferred due to its more predictable behavior: // @match :/// The @match directive is more strict and will only work with http, https, or ftp schemes, while @include can potentially work with file URLs and other schemes when supported by the userscript manager. Here is an example of a working userscript that employs the @include directive with the correct wildcard syntax: // ==UserScript== // @name Global Userscript // @namespace http://tampermonkey.net/ // @version 1.0 // @description Run on all websites. // @include :///* // @grant none // ==/UserScript== (function() { ‘use strict’; // Your code here… })(); Save this script in Tampermonkey to have it run on all webpages you visit. Note that your userscript manager (like Tampermonkey) may warn you about using such broad matches, as it’s a security risk to allow scripts to run on all pages—including sensitive pages like online banking or email. Always be cautious with the permissions you grant to your userscripts. Tampermonkey® by Jan Biniok Home Userscripts Support Changes Contribute About FAQ Documentation Table of Contents Userscript Header @name The name of the script. Internationalization is done by adding an appendix naming the locale. // @name A test // @name:de Ein Test @namespace The namespace of the script. @copyright A copyright statement shown at the header of the script's editor right below the script name. @version The script version. This is used for the update check and needs to be increased at every update. In this list the next entry is considered to be a higher version number, eg: Alpha-v1 < Alpha-v2 and 16.4 == 16.04 Alpha-v1 Alpha-v2 Alpha-v10 Beta 0.5pre3 0.5prelimiary 0.6pre4 0.6pre5 0.7pre4 0.7pre10 1.-1 1 == 1. == 1.0 == 1.0.0 1.1a 1.1aa 1.1ab 1.1b 1.1c 1.1.-1 1.1 == 1.1.0 == 1.1.00 1.1.1.1.1 1.1.1.1.2 1.1.1.1 1.10.0-alpha 1.10 == 1.10.0 1.11.0-0.3.7 1.11.0-alpha 1.11.0-alpha.1 1.11.0-alpha+1 1.12+1 == 1.12+1.0 1.12+1.1 == 1.12+1.1.0 1.12+2 1.12+2.1 1.12+3 1.12+4 1.12 2.0 16.4 == 16.04 2023-08-17.alpha 2023-08-17 2023-08-17_14-04 == 2023-08-17_14-04.0 2023-08-17+alpha 2023-09-11_14-0 @description A short significant description. Internationalization is done by adding an appendix naming the locale. // @description This userscript does wonderful things // @description:de Dieses Userscript tut wundervolle Dinge @icon, @iconURL, @defaulticon The script icon in low res. @icon64, @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. @grant @grant is used to whitelist GM_* and GM.* functions, the unsafeWindow object and some powerful window functions. // @grant GM_setValue // @grant GM_getValue // @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. In case @grant is followed by none the sandbox is disabled. In this mode no GM_* function but the GM_info property will be available. // @grant none If no @grant tag is given an empty list is assumed. However this different from using none. @author The scripts author. @homepage, @homepageURL, @website, @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. @antifeature This tag allows script developers to disclose whether they monetize their scripts. It is for example required by GreasyFork. Syntax: <tag> <type> <description> <type> can have the following values: ads tracking miner // @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. @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! // @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. // @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. @include 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 // @include http://www.tampermonkey.net/* // @include http://* // @include https://* // @include /^https://www.tampermonkey.net/.*/ // @include * 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 ://. @match In Tampermonkey, the @match directive is used to specify the web pages that your script should run on. The value of @match should be a URL pattern that matches the pages you want your script to run on. Here are the parts of the URL pattern that you'll need to set: // @match <protocol>://<domain><path> protocol - This is the first part of the URL, before the colon. It specifies the protocol that the page uses, such as http or https. * matches both. domain - This is the second part of the URL, after the protocol and two slashes. It specifies the domain name of the website, such as tmnk.com. You can use the wildcard character this way *.tmnk.net to match tmnk.net and any sub-domain of it like www.tmnk.net. path - This is the part of the URL that comes after the domain name, and may include additional subdirectories or filenames. You can use the wildcard character * to match any part of the path. Please check this documentation to get more information about match pattern. Note: the <all_urls> statement is not yet supported and the scheme part also accepts http*://. Multiple tag instances are allowed. More examples: // @match *://*/* // @match https://*/* // @match http://*/foo* // @match https://*.tampermonkey.net/foo*bar @exclude Exclude URLs even it they are included by @include or @match. 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 document-start The script will be injected as fast as possible. // @run-at document-body The script will be injected if the body element exists. // @run-at document-end The script will be injected when or after the DOMContentLoaded event was dispatched. // @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. // @run-at context-menu The script will be injected if it is clicked at the browser context menu. Note: all @include and @exclude statements will be ignored if this value is used, but this may change in the future. @sandbox @sandbox allows Tampermonkey to decide where the userscript is injected: MAIN_WORLD - the page ISOLATED_WORLD - the extension's content script USERSCRIPT_WORLD - a special context created for userscripts But instead of specifying an environment, the userscript can express what exactly it needs access to. @sandbox supports three possible arguments: raw "Raw" access means that a script for compatibility reasons always needs to run in page context, the MAIN_WORLD. At the moment this mode is the default if @sandbox is omitted. If injection into the MAIN_WORLD is not possible (e.g. because of a CSP) the userscript will be injected into other (enabled) sandboxes according to the order of this list. JavaScript "JavaScript" access mode means that this script needs access to unsafeWindow. At Firefox a special context, the USERSCRIPT_WORLD, is created which also bypasses existing CSPs. It however, might create new issues since now cloneInto and exportFunction are necessary to share objects with the page. raw mode is used as fallback at other browsers. DOM Use this access mode if the script only needs DOM and no direct unsafeWindow access. If enabled these scripts are executed inside the extension context, the ISOLATED_WORLD, or at any other enabled context otherwise, because they all grant DOM access. // @sandbox JavaScript @connect This tag defines the domains (no top-level domains) including subdomains which are allowed to be retrieved by GM_xmlhttpRequest // @connect <value> <value> can be: a domain name like example.com (this will also allow all subdomains). a subdomain name like subdomain.example.com. self to whitelist the domain the script is currently running at. localhost to access the localhost. an IP address like 1.2.3.4. *. 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 to avoid the confirmation dialog for most users. Additionally add @connect * to the script to allow Tampermonkey to offer an "Always allow all domains" button. 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. Multiple tag instances are allowed. More examples: // @connect tmnk.net // @connect www.tampermonkey.net // @connect self // @connect localhost // @connect 8.8.8.8 // @connect * @noframes This tag makes the script running on the main pages, but not at iframes. @updateURL An update URL for the userscript. Note: a @version tag is required to make update checks work. @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. @supportURL Defines the URL where the user can report issues and get personal support. @webRequest @webRequest takes a JSON document that matches GM_webRequest's rule parameter. It allows the rules to apply even before the userscript is loaded. @unwrap Injects the userscript without any wrapper and sandbox into the page, which might be useful for Scriptlets. Application Programming Interface unsafeWindow The unsafeWindow object provides access to the window object of the page that Tampermonkey is running on, rather than the window object of the Tampermonkey extension. This can be useful in some cases, such as when a userscript needs to access a JavaScript library or variable that is defined on the page. Subresource Integrity Subresource Integrity (SRI) is a security feature that allows userscript developers to ensure that the external resources (such as JavaScript libraries and CSS files) that they include in their userscript have not been tampered with or modified. This is accomplished by generating a cryptographic hash of the resource and including it in @require and @resource tags. When the userscript is installed, Tampermonkey will calculate the hash of the resource and compare it to the included hash. If the two hashes do not match, Tampermonkey will refuse to load the resource, preventing attackers from injecting malicious code into your userscript. The hash component of the URL of @resource and @require tags is used for this purpose. // @resource SRIsecured1 http://example.com/favicon1.ico#md5=ad34bb... // @resource SRIsecured2 http://example.com/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= Tampermonkey 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 Tampermonkey. All hashes need to be encoded in either hex or Base64 format. GM_addElement(tag_name, attributes), GM_addElement(parent_node, tag_name, attributes) GM_addElement allows Tampermonkey scripts to add new elements to the page that Tampermonkey is running on. This can be useful for a variety of purposes, such as adding script and img tags if the page limits these elements with a content security policy (CSP). It 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: script tag img tag style tag 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. GM_addStyle(css) Adds the given style to the document and returns the injected style element. GM_download(details), GM_download(url, name) GM_download allows userscripts to download a file from a specified URL and save it to the user's local machine. The GM_download function takes the following parameters: details can have the following attributes: url: The URL of the file to download. This must be a valid URL and must point to a file that is accessible to the user. name: The name to use for the downloaded file. This should include the file's extension, such as .txt or .pdf. For security reasons the file extension needs to be whitelisted at Tampermonkey's options page headers: An object containing HTTP headers to include in the download request. See GM_xmlhttpRequest for more details. saveAs: A boolean value indicating whether to use the user's default download location, or to prompt the user to choose a different location. This option works in browser API mode only. conflictAction: A string that control what happens when a file with this name already exists. This option works in browser API mode only. Possible values are uniquify, overwrite and prompt. Please check this link for more details. onload: A function to call when the download has completed successfully. onerror: A function to call if the download fails or is cancelled. onprogress A callback to be executed if this download made some progress. ontimeout A callback to be executed if this download failed due to a timeout. The download argument of the onerror callback can have the following attributes: 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: detail about that error Returns an object with the following property: abort: A function which can be called to cancel this download. If GM.download is used it returns a promise that resolves to the download details and also has an abort function. 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_download("http://example.com/file.txt", "file.txt"); const download = GM_download({ url: "http://example.com/file.txt", name: "file.txt", saveAs: true }); // cancel download after 5 seconds window.setTimeout(() => download.abort(), 5000); Note: The browser might modify the desired filename. Especially a file extension might be added if the browser finds this to be safe to download at the current OS. GM_getResourceText(name) Allows userscripts to access the text of a resource (such as a JavaScript or CSS file) that has been included in a userscript via @resource. The function takes a single parameter, which is the "name" of the resource to retrieve. It returns the text of the resource as a string. Here is an example of how the function might be used: const scriptText = GM_getResourceText("myscript.js"); const scriptText2 = await GM.getResourceText("myscript.js"); const script = document.createElement("script"); script.textContent = scriptText; document.body.appendChild(script); GM_getResourceURL(name) GM_getResourceURL allows userscripts to access the URL of a resource (such as a CSS or image file) that has been included in the userscript via a @resource tag at the script header. The function takes a single parameter, which is the "name" of the resource to retrieve. It returns the URL of the resource as a string. const imageUrl = GM_getResourceURL("myimage.png"); const imageUrl2 = await GM.getResourceURL("myimage.png"); const image = document.createElement("img"); image.src = imageUrl; document.body.appendChild(image); GM_info Get some info about the script and TM. The object might look like this: type ScriptGetInfo = { downloadMode: string, isFirstPartyIsolation?: boolean, isIncognito: boolean, sandboxMode: SandboxMode, scriptHandler: string, scriptMetaStr: string | null, scriptUpdateURL: string | null, scriptWillUpdate: boolean, version?: string, script: { antifeatures: { [antifeature: string]: { [locale: string]: string } }, author: string | null, blockers: string[], connects: string[], copyright: string | null, deleted?: number | undefined, description_i18n: { [locale: string]: string } | null, description: string, downloadURL: string | null, excludes: string[], fileURL: string | null, grant: string[], header: string | null, homepage: string | null, icon: string | null, icon64: string | null, includes: string[], lastModified: number, matches: string[], name_i18n: { [locale: string]: string } | null, name: string, namespace: string | null, position: number, resources: Resource[], supportURL: string | null, system?: boolean | undefined, 'run-at': string | null, unwrap: boolean | null, updateURL: string | null, version: string, webRequest: WebRequestRule[] | null, options: { check_for_updates: boolean, comment: string | null, compatopts_for_requires: boolean, compat_wrappedjsobject: boolean, compat_metadata: boolean, compat_foreach: boolean, compat_powerful_this: boolean | null, sandbox: string | null, noframes: boolean | null, unwrap: boolean | null, run_at: string | null, tab_types: string | null, override: { use_includes: string[], orig_includes: string[], merge_includes: boolean, use_matches: string[], orig_matches: string[], merge_matches: boolean, use_excludes: string[], orig_excludes: string[], merge_excludes: boolean, use_connects: string[], orig_connects: string[], merge_connects: boolean, use_blockers: string[], orig_run_at: string | null, orig_noframes: boolean | null } } } }; type SandboxMode = 'js' | 'raw' | 'dom'; type Resource = { name: string, url: string, error?: string, content?: string, meta?: string }; type WebRequestRule = { selector: { include?: string | string[], match?: string | string[], exclude?: string | string[] } | string, action: string | { cancel?: boolean, redirect?: { url: string, from?: string, to?: string } | string } }; GM_log(message) Log a message to the console. GM_notification(details, ondone), GM_notification(text, title, image, onclick) GM_notification allows users to display notifications on the screen, using a provided message and other optional parameters. The function takes several parameters. Either a details object or multiple parameters. The details object can have the following attributes, from which some can also be used as direct parameter. The available options include: text: A string containing the message to display in the notification. title: The title of the notification. tag: v5.0+ This tag will be used to identify this notification. This way you can update existing notifications by calling GM_notification again and using the same tag. If you don't provide a tag, a new notification will be created every time. image: The URL of an image to display in the notification. highlight: A boolean flag whether to highlight the tab that sends the notfication (required unless text is set) silent: A boolean flag whether to not play a sound timeout: The time, in milliseconds, after which the notification should automatically close. url: v5.0+ A URL to load when the user clicks on the notification. You can prevent loading the URL by calling event.preventDefault() in the onclick event handler. onclick: A callback function that will be called when the user clicks on the notification. ondone A callback function that will be called when the notification is closed (no matter if this was triggered by a timeout or a click) or the tab was highlighted The function does not return a value. If no url and no tag is provided the notification will closed when the userscript unloads v5.0+(e.g. when the page is reloaded or the tab is closed). Here is an example of how the function might be used: GM_notification({ text: "This is the notification message.", title: "Notification Title", url: 'https:/example.com/', onclick: (event) => { // The userscript is still running, so don't open example.com event.preventDefault(); // Display an alert message instead alert('I was clicked!') } }); const clicked = await GM.notification({ text: "Click me." }); GM_openInTab(url, options), GM_openInTab(url, loadInBackground) GM_openInTab allows userscripts to open a new tab in the browser and navigate to a specified URL. The function takes two parameters: A string names "url" containing the URL of the page to open in the new tab. An optional options object that can be used to customize the behavior of the new tab. The available options include: active: A boolean value indicating whether the new tab should be active (selected) or not. The default is false. insert: An integer indicating the position at which the new tab should be inserted in the tab strip. The default is false, which means the new tab will be added to the end of the tab strip. setParent: A boolean value indicating whether the new tab should be considered a child of the current tab. The default is false. incognito A boolean value that makes the tab being opened inside a incognito mode/private mode window. loadInBackground A boolean value has the opposite meaning of active and was added to achieve Greasemonkey 3.x compatibility. The function returns an object with the function close, the listener onclose and a flag called closed. Here is an example of how the function might be used: // Open a new tab and navigate to the specified URL GM_openInTab("https://www.example.com/"); GM_registerMenuCommand(name, callback, options_or_accessKey) GM_registerMenuCommand allows userscripts to add a new entry to the userscript's menu in the browser, and specify a function to be called when the menu item is selected. The function takes three parameters: name - string, A string containing the text to display for the menu item. callback - function, A function to be called when the menu item is selected. The function will be passed a single parameter, which is the currently active tab. As of Tampermonkey 4.14 a MouseEvent or KeyboardEvent is passed as function argument. accessKey - string?, An optional access key. Please see the description below. Either options or accessKey can be specified. options v4.20+ object?, Optional options that can be used to customize the menu item. The options are specified as an object with the following properties: id v5.0+ number|string?, An optional number that was returned by a previous GM_registerMenuCommand call. If specified, the according menu item will be updated with the new options. If not specified or the menu item can't be found, a new menu item will be created. accessKey - string?, An optional access key for the menu item. This can be used to create a shortcut for the menu item. For example, if the access key is "s", the user can select the menu item by pressing "s" when Tampermonkey's popup-menu is open. Please note that there are browser-wide shortcuts configurable to open Tampermonkey's popup-menu. autoClose - boolean?, An optional boolean parameter that specifies whether the popup menu should be closed after the menu item is clicked. The default value is true. Please note that this setting has no effect on the menu command section that is added to the page's context menu. title v5.0+ - string?, An optional string that specifies the title of the menu item. This is displayed as a tooltip when the user hovers the mouse over the menu item. The function return a menu entry ID that can be used to unregister the command. Here is an example of how the function might be used: const menu_command_id_1 = GM_registerMenuCommand("Show Alert", function(event: MouseEvent | KeyboardEvent) { alert("Menu item selected"); }, { accessKey: "a", autoClose: true }); const menu_command_id_2 = GM_registerMenuCommand("Log", function(event: MouseEvent | KeyboardEvent) { console.log("Menu item selected"); }, "l"); GM_unregisterMenuCommand(menuCmdId) GM_unregisterMenuCommand removes an existing entry from the userscript's menu in the browser. The function takes a single parameter, which is the ID of the menu item to remove. It does not return a value. Here is an example of how the function might be used: const menu_command_id = GM_registerMenuCommand(...); GM_unregisterMenuCommand(menu_command_id); GM_setClipboard(data, info, cb) GM_setClipboard sets the text of the clipboard to a specified value. The function takes a parameter "data", which is the string to set as the clipboard text, a parameter "info" and an optional callback function "cb". "info" can be just a string expressing the type text or html or an object like "cb" is an optional callback function that is called when the clipboard has been set. { type: 'text', mimetype: 'text/plain' } GM_setClipboard("This is the clipboard text.", "text", () => console.log("Clipboard set!")); await GM.setClipboard("This is the newer clipboard text.", "text"); console.log('Clipboard set again!'); GM_getTab(callback) The GM_getTab function takes a single parameter, a callback function that will be called with an object that is persistent as long as this tab is open. GM_getTab((tab) => console.log(tab)); const t = await GM.getTab(); console.log(t); GM_saveTab(tab, cb) The GM_saveTab function allows a userscript to save information about a tab for later use. The function takes a "tab" parameter, which is an object containing the information to be saved about the tab and an optional callback function "cb". The GM_saveTab function saves the provided tab information, so that it can be retrieved later using the GM_getTab function. Here is an example of how the GM_saveTab function might be used in a userscript: GM_getTab(function(tab) { tab.newInfo = "new!"; GM_saveTab(tab); }); await GM.saveTab(tab); In this example, the GM_saveTab function is called with the tab object returned by the GM_getTab function, and a new key called "newInfo". GM_getTabs(callback) The GM_getTabs function takes a single parameter: a callback function that will be called with the information about the tabs. The "tabs" object that is passed to the callback function contains objects, with each object representing the saved tab information stored by GM_saveTab. GM_getTabs((tabs) => { for (const [tabId, tab] of Object.entries(tabs)) { console.log(`tab {tabId}`, tab); } }); const tabs = await GM.getTabs(); GM_setValue(key, value) The GM_setValue allows a userscript to set the value of a specific key in the userscript's storage. The GM_setValue function takes two parameters: A string specifying the key for which the value should be set. The value to be set for the key. Values (including nested object properties) can be null or of type "object", "string", "number", "undefined" or "boolean". The GM_setValue function does not return any value. Instead, it sets the provided value for the specified key in the userscript's storage. Here is an example of how GM_setValue and its async pendant GM.setValue might be used in a userscript: GM_setValue("someKey", "someData"); await GM.setValue("otherKey", "otherData"); GM_getValue(key, defaultValue) The GM_getValue function allows a userscript to retrieve the value of a specific key in the extension's storage. It takes two parameters: A string specifying the key for which the value should be retrieved. A default value to be returned if the key does not exist in the extension's storage. This default value can be of any type (string, number, object, etc.). The GM_getValue function returns the value of the specified key from the extension's storage, or the default value if the key does not exist. Here is an example of how the GM_getValue function might be used in a userscript: const someKey = GM_getValue("someKey", null); const otherKey = await GM.getValue("otherKey", null); In this example, the GM_getValue function is called with the key "someKey" and a default value of null. If the "someKey" key exists in the extension's storage, its value will be returned and stored in the someKey variable. If the key does not exist, the default value of null will be returned and stored in the savedTab variable. GM_deleteValue(key) Deletes "key" from the userscript's storage. GM_deleteValue("someKey"); await GM.deleteValue("otherKey"); GM_listValues() The GM_listValues function returns a list of keys of all stored data. const keys = GM_listValues(); const asyncKeys = await GM.listValues(); GM_addValueChangeListener(key, (key, old_value, new_value, remote) => void) The GM_addValueChangeListener function allows a userscript to add a listener for changes to the value of a specific key in the userscript's storage. The function takes two parameters: A string specifying the key for which changes should be monitored. A callback function that will be called when the value of the key changes. The callback function should have the following signature: function(key, oldValue, newValue, remote) { // key is the key whose value has changed // oldValue is the previous value of the key // newValue is the new value of the key // remote is a boolean indicating whether the change originated from a different userscript instance } The GM_addValueChangeListener function returns a "listenerId" value that can be used to remove the listener later using the GM_removeValueChangeListener function. The very same applies to GM.addValueChangeListener and GM.removeValueChangeListener with the only difference that both return a promise; Here is an example of how the GM_addValueChangeListener function might be used in a userscript: // Add a listener for changes to the "savedTab" key var listenerId = GM_addValueChangeListener("savedTab", function(key, oldValue, newValue, remote) { // Print a message to the console when the value of the "savedTab" key changes console.log("The value of the '" + key + "' key has changed from '" + oldValue + "' to '" + newValue + "'"); }); GM_addValueChangeListener can be used by userscripts to communicate with other userscript instances at other tabs. GM_removeValueChangeListener(listenerId) GM_removeValueChangeListener and GM.removeValueChangeListener both get one argument called "listenerId" and remove the change listener with this ID. GM_xmlhttpRequest(details) The GM_xmlhttpRequest allows a userscripts to send an HTTP request and handle the response. The function takes a single parameter: an object containing the details of the request to be sent and the callback functions to be called when the response is received. The object can have the following properties: method - string, one of GET, HEAD, POST url - string|URL, the destination URL headers e.g. user-agent, referer, ... (some special headers are not supported by Safari and Android browsers) data - string|Blob|File|Object|Array|FormData|URLSearchParams?, some data to send via a POST request redirect one of follow, error or manual; controls what to happen when a redirect is detected (build 6180+, enforces fetch mode) 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 request (enforces fetch mode) fetch use a fetch instead of a XMLHttpRequest request (at Chrome this causes details.timeout and xhr.onprogress to not work and makes xhr.onreadystatechange receive only readyState DONE (==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 readyState changed ontimeout callback to be executed if the request failed due to a timeout onload callback to be executed if the request was loaded. function(response) { // response is an object containing the details of the response } response has the following attributes: finalUrl - the final URL after all redirects from where the data was loaded readyState - the request's readyState status - the request's status statusText - the request's status text responseHeaders - the request's response headers response - the response data as object if details.responseType was set responseXML - the response data as XML document responseText - the response data as plain string GM_xmlhttpRequest returns an object with the following property: abort - function to be called to cancel this request GM.xmlHttpRequest returns a promise that resolves to the response and also has an abort function. Here is an example of how the GM_xmlhttpRequest function might be used in a userscript: GM_xmlhttpRequest({ method: "GET", url: "https://example.com/", headers: { "Content-Type": "application/json" }, onload: function(response) { console.log(response.responseText); } }); const r = await GM.xmlHttpRequest({ url: "https://example.com/" }).catch(e => console.error(e)); console.log(r.responseText); 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. GM_webRequest(rules, listener) Note: this API is experimental and might change at any time. It might also disappear or change during manifest v3 migration. GM_webRequest (re-)registers rules for web request manipulations and the listener of triggered rules. If you need to just register rules it's better to use @webRequest header. Note, webRequest proceeds only requests with types sub_frame, script, xhr and websocket. Parameters: rules - object[], array of rules with following properties: selector - string|object, for which URLs the rule should be triggered, string value is shortening for { include: [selector] }, object properties: include - string|string[], URLs, patterns, and regexpes for rule triggering; match - string|string[], URLs and patterns for rule trigering; exclude - string|string[], URLs, patterns, and regexpes for not triggering the rule; action - string|object, what to do with the request, string value "cancel" is shortening for { cancel: true }, object properties: cancel - boolean, whether to cancel the request; redirect - string|object, redirect to some URL which must be included in any @match or @include header. When a string, redirects to the static URL. If object: from - string, a regexp to extract some parts of the URL, e.g. "([^:]+)://match.me/(.*)"; to - string, pattern for substitution, e.g. "1://redirected.to/2"; listener - function, is called when the rule is triggered, cannot impact on the rule action, arguments: info - string, type of action: "cancel", "redirect"; message - string, "ok" or "error"; details - object, info about the request and rule: rule - object, the triggered rule; url - string, URL of the request; redirect_url - string, where the request was redirected; description - string, error description. Example GM_webRequest([ { selector: '*cancel.me/*', action: 'cancel' }, { selector: { include: '*', exclude: 'http://exclude.me/*' }, action: { redirect: 'http://new_static.url' } }, { selector: { match: '*://match.me/*' }, action: { redirect: { from: '([^:]+)://match.me/(.*)', to: '1://redirected.to/2' } } } ], function(info, message, details) { console.log(info, message, details); }); GM_cookie.list(details[, callback]) Note: the GM_cookie API is experimental and might return a not supported error at some Tampermonkey versions. Tampermonkey checks if the script has @include or @match access to given details.url arguments! Parameters: details object, containing properties of the cookies to retrieve url string?, representing the URL to retrieve cookies from (defaults to current document URL) domain string?, representing the domain of the cookies to retrieve name string?, representing the name of the cookies to retrieve path string?, representing the path of the cookies to retrieve callback function?, to be called when the cookies have been retrieved. The function will be passed two arguments: cookies object[], representing the retrieved cookies error string, representing an error message if an error occurred, null otherwise. The cookie objects have the following properties: domain string, representing the domain of the cookie firstPartyDomain string?: the first party domain of the cookie. hostOnly boolean, indicating whether the cookie is a host-only cookie httpOnly boolean, indicating whether the cookie is an HTTP-only cookie name string, representing the name of the cookie path string, representing the path of the cookie sameSite string, indicating the SameSite attribute of the cookie secure boolean, indicating whether the cookie requires a secure connection session boolean, indicating whether the cookie is a session cookie value string, representing the value of the cookie Example usage: // Retrieve all cookies with name "mycookie" GM_cookie.list({ name: "mycookie" }, function(cookies, error) { if (!error) { console.log(cookies); } else { console.error(error); } }); // Retrieve all cookies for the current domain const cookies = await GM.cookies.list() console.log(cookies); GM_cookie.set(details[, callback]) Sets a cookie with the given details. Supported properties are defined here. Parameters: details: An object containing the details of the cookie to be set. The object can have the following properties: url string?, the URL to associate the cookie with. If not specified, the cookie is associated with the current document's URL. name string, the name of the cookie. value string, the value of the cookie. domain string?, the domain of the cookie. firstPartyDomain string?: the first party domain of the cookie. path string?, the path of the cookie. secure boolean?, whether the cookie should only be sent over HTTPS. httpOnly boolean?, whether the cookie should be marked as HttpOnly. expirationDate number?, the expiration date of the cookie in seconds since the Unix epoch. If not specified, the cookie never expires. callback function?, a function to be called when the operation is complete. The function is passed one argument: error string?, if there was an error setting the cookie, this contains an error message. Otherwise, it is undefined. Example: GM_cookie.set({ url: 'https://example.com', name: 'name', value: 'value', domain: '.example.com', path: '/', secure: true, httpOnly: true, expirationDate: Math.floor(Date.now() / 1000) + (60 * 60 * 24 * 30) // Expires in 30 days }, function(error) { if (error) { console.error(error); } else { console.log('Cookie set successfully.'); } }); GM.cookie.set({ name: 'name', value: 'value' }) .then(() => { console.log('Cookie set successfully.'); }) .catch((error) => { console.error(error); }); GM_cookie.delete(details, callback) Deletes a cookie. Parameters: The details object must contain at least one of the following properties: url string?, the URL associated with the cookie. If url is not specified, the current document's URL will be used. name string?, the name of the cookie to delete. firstPartyDomain string?: the first party domain of the cookie to delete. The callback function is optional and will be called when the cookie has been deleted or an error has occurred. It takes one argument: error string?, an error message, or undefined if the cookie was deleted successfully. Example: GM_cookie.delete({ name: 'cookie_name' }, function(error) { if (error) { console.error(error); } else { console.log('Cookie deleted successfully'); } }); window.onurlchange If a script runs on a single-page application, then it can use window.onurlchange to listen for URL changes: // ==UserScript== ... // @grant window.onurlchange // ==/UserScript== if (window.onurlchange === null) { // feature is supported window.addEventListener('urlchange', (info) => ...); } window.close Usually JavaScript is not allowed to close tabs via window.close. Userscripts, however, can do this if the permission is requested via @grant. Note: for security reasons it is not allowed to close the last tab of a window. // ==UserScript== ... // @grant window.close // ==/UserScript== if (condition) { window.close(); } window.focus window.focus brings the window to the front, while unsafeWindow.focus may fail due to user settings. // ==UserScript== ... // @grant window.focus // ==/UserScript== if (condition) { window.focus(); } <><![CDATA[...]]></> CDATA-based way of storing meta data is supported via compatibility option. Tampermonkey tries to automatically detect whether a script needs this option to be enabled. var inline_src = (<><![CDATA[ console.log('Hello World!'); ]]></>).toString(); eval(inline_src); Imprint Privacy Policy

answer:It looks like you're interested in creating a userscript using Tampermonkey for Firefox that can clear cookies and cache data for websites with the ".com" domain every 10 seconds. However, based on your request, it seems like there is confusion with the usage of the `@match` directive and the abilities of a userscript. Here's a simplified script with the correct match patterns for `.com` pages and an attempt to delete cookies every 10 seconds. Note that this won't be effective for clearing cache or HttpOnly cookies and will only delete cookies that can be accessed via JavaScript. Clearance of such data often requires browser intervention or extension permissions not granted to typical userscripts: ```javascript // ==UserScript== // @name Auto Clear Cookies for .com Domains // @namespace http://tampermonkey.net/ // @version 1.0 // @description Try to clear cookies for .com domains every 10 seconds. // @match http://*.com/* // @match https://*.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // This function attempts to delete all accessible cookies for the current .com domain function deleteCookies() { var cookies = document.cookie.split(";"); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie.trim(); document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; } } // Set an interval to periodically delete cookies setInterval(deleteCookies, 10000); })(); ``` Keep in mind the following: 1. You need Tampermonkey extension installed in Firefox to run this script. 2. After installing the script, it will run on `.com` domains and attempt to clear cookies accessible to JavaScript. 3. The script will not clear cache or any HttpOnly/Secure cookies. 4. Userscripts can't clear browser cache due to limited permissions. To install the script, copy it into Tampermonkey's "Create a new script" section and save it. It will then automatically execute every 10 seconds when you browse a website with the `.com` domain. Always remember that browsers place certain restrictions on what userscripts can do for security reasons, and fully clearing browser data typically requires additional permissions or manual action by the user.

question:Tampermonkey® by Jan Biniok Home Userscripts Support Changes Contribute About FAQ Documentation Table of Contents Userscript Header @name The name of the script. Internationalization is done by adding an appendix naming the locale. // @name A test // @name:de Ein Test @namespace The namespace of the script. @copyright A copyright statement shown at the header of the script's editor right below the script name. @version The script version. This is used for the update check and needs to be increased at every update. In this list the next entry is considered to be a higher version number, eg: Alpha-v1 < Alpha-v2 and 16.4 == 16.04 Alpha-v1 Alpha-v2 Alpha-v10 Beta 0.5pre3 0.5prelimiary 0.6pre4 0.6pre5 0.7pre4 0.7pre10 1.-1 1 == 1. == 1.0 == 1.0.0 1.1a 1.1aa 1.1ab 1.1b 1.1c 1.1.-1 1.1 == 1.1.0 == 1.1.00 1.1.1.1.1 1.1.1.1.2 1.1.1.1 1.10.0-alpha 1.10 == 1.10.0 1.11.0-0.3.7 1.11.0-alpha 1.11.0-alpha.1 1.11.0-alpha+1 1.12+1 == 1.12+1.0 1.12+1.1 == 1.12+1.1.0 1.12+2 1.12+2.1 1.12+3 1.12+4 1.12 2.0 16.4 == 16.04 2023-08-17.alpha 2023-08-17 2023-08-17_14-04 == 2023-08-17_14-04.0 2023-08-17+alpha 2023-09-11_14-0 @description A short significant description. Internationalization is done by adding an appendix naming the locale. // @description This userscript does wonderful things // @description:de Dieses Userscript tut wundervolle Dinge @icon, @iconURL, @defaulticon The script icon in low res. @icon64, @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. @grant @grant is used to whitelist GM_* and GM.* functions, the unsafeWindow object and some powerful window functions. // @grant GM_setValue // @grant GM_getValue // @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. In case @grant is followed by none the sandbox is disabled. In this mode no GM_* function but the GM_info property will be available. // @grant none If no @grant tag is given an empty list is assumed. However this different from using none. @author The scripts author. @homepage, @homepageURL, @website, @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. @antifeature This tag allows script developers to disclose whether they monetize their scripts. It is for example required by GreasyFork. Syntax: <tag> <type> <description> <type> can have the following values: ads tracking miner // @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. @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! // @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. // @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. @include 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 // @include http://www.tampermonkey.net/* // @include http://* // @include https://* // @include /^https://www.tampermonkey.net/.*/ // @include * 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 ://. @match In Tampermonkey, the @match directive is used to specify the web pages that your script should run on. The value of @match should be a URL pattern that matches the pages you want your script to run on. Here are the parts of the URL pattern that you'll need to set: // @match <protocol>://<domain><path> protocol - This is the first part of the URL, before the colon. It specifies the protocol that the page uses, such as http or https. * matches both. domain - This is the second part of the URL, after the protocol and two slashes. It specifies the domain name of the website, such as tmnk.com. You can use the wildcard character this way *.tmnk.net to match tmnk.net and any sub-domain of it like www.tmnk.net. path - This is the part of the URL that comes after the domain name, and may include additional subdirectories or filenames. You can use the wildcard character * to match any part of the path. Please check this documentation to get more information about match pattern. Note: the <all_urls> statement is not yet supported and the scheme part also accepts http*://. Multiple tag instances are allowed. More examples: // @match *://*/* // @match https://*/* // @match http://*/foo* // @match https://*.tampermonkey.net/foo*bar @exclude Exclude URLs even it they are included by @include or @match. 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 document-start The script will be injected as fast as possible. // @run-at document-body The script will be injected if the body element exists. // @run-at document-end The script will be injected when or after the DOMContentLoaded event was dispatched. // @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. // @run-at context-menu The script will be injected if it is clicked at the browser context menu. Note: all @include and @exclude statements will be ignored if this value is used, but this may change in the future. @sandbox @sandbox allows Tampermonkey to decide where the userscript is injected: MAIN_WORLD - the page ISOLATED_WORLD - the extension's content script USERSCRIPT_WORLD - a special context created for userscripts But instead of specifying an environment, the userscript can express what exactly it needs access to. @sandbox supports three possible arguments: raw "Raw" access means that a script for compatibility reasons always needs to run in page context, the MAIN_WORLD. At the moment this mode is the default if @sandbox is omitted. If injection into the MAIN_WORLD is not possible (e.g. because of a CSP) the userscript will be injected into other (enabled) sandboxes according to the order of this list. JavaScript "JavaScript" access mode means that this script needs access to unsafeWindow. At Firefox a special context, the USERSCRIPT_WORLD, is created which also bypasses existing CSPs. It however, might create new issues since now cloneInto and exportFunction are necessary to share objects with the page. raw mode is used as fallback at other browsers. DOM Use this access mode if the script only needs DOM and no direct unsafeWindow access. If enabled these scripts are executed inside the extension context, the ISOLATED_WORLD, or at any other enabled context otherwise, because they all grant DOM access. // @sandbox JavaScript @connect This tag defines the domains (no top-level domains) including subdomains which are allowed to be retrieved by GM_xmlhttpRequest // @connect <value> <value> can be: a domain name like example.com (this will also allow all subdomains). a subdomain name like subdomain.example.com. self to whitelist the domain the script is currently running at. localhost to access the localhost. an IP address like 1.2.3.4. *. 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 to avoid the confirmation dialog for most users. Additionally add @connect * to the script to allow Tampermonkey to offer an "Always allow all domains" button. 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. Multiple tag instances are allowed. More examples: // @connect tmnk.net // @connect www.tampermonkey.net // @connect self // @connect localhost // @connect 8.8.8.8 // @connect * @noframes This tag makes the script running on the main pages, but not at iframes. @updateURL An update URL for the userscript. Note: a @version tag is required to make update checks work. @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. @supportURL Defines the URL where the user can report issues and get personal support. @webRequest @webRequest takes a JSON document that matches GM_webRequest's rule parameter. It allows the rules to apply even before the userscript is loaded. @unwrap Injects the userscript without any wrapper and sandbox into the page, which might be useful for Scriptlets. Application Programming Interface unsafeWindow The unsafeWindow object provides access to the window object of the page that Tampermonkey is running on, rather than the window object of the Tampermonkey extension. This can be useful in some cases, such as when a userscript needs to access a JavaScript library or variable that is defined on the page. Subresource Integrity Subresource Integrity (SRI) is a security feature that allows userscript developers to ensure that the external resources (such as JavaScript libraries and CSS files) that they include in their userscript have not been tampered with or modified. This is accomplished by generating a cryptographic hash of the resource and including it in @require and @resource tags. When the userscript is installed, Tampermonkey will calculate the hash of the resource and compare it to the included hash. If the two hashes do not match, Tampermonkey will refuse to load the resource, preventing attackers from injecting malicious code into your userscript. The hash component of the URL of @resource and @require tags is used for this purpose. // @resource SRIsecured1 http://example.com/favicon1.ico#md5=ad34bb... // @resource SRIsecured2 http://example.com/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= Tampermonkey 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 Tampermonkey. All hashes need to be encoded in either hex or Base64 format. GM_addElement(tag_name, attributes), GM_addElement(parent_node, tag_name, attributes) GM_addElement allows Tampermonkey scripts to add new elements to the page that Tampermonkey is running on. This can be useful for a variety of purposes, such as adding script and img tags if the page limits these elements with a content security policy (CSP). It 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: script tag img tag style tag 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. GM_addStyle(css) Adds the given style to the document and returns the injected style element. GM_download(details), GM_download(url, name) GM_download allows userscripts to download a file from a specified URL and save it to the user's local machine. The GM_download function takes the following parameters: details can have the following attributes: url: The URL of the file to download. This must be a valid URL and must point to a file that is accessible to the user. name: The name to use for the downloaded file. This should include the file's extension, such as .txt or .pdf. For security reasons the file extension needs to be whitelisted at Tampermonkey's options page headers: An object containing HTTP headers to include in the download request. See GM_xmlhttpRequest for more details. saveAs: A boolean value indicating whether to use the user's default download location, or to prompt the user to choose a different location. This option works in browser API mode only. conflictAction: A string that control what happens when a file with this name already exists. This option works in browser API mode only. Possible values are uniquify, overwrite and prompt. Please check this link for more details. onload: A function to call when the download has completed successfully. onerror: A function to call if the download fails or is cancelled. onprogress A callback to be executed if this download made some progress. ontimeout A callback to be executed if this download failed due to a timeout. The download argument of the onerror callback can have the following attributes: 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: detail about that error Returns an object with the following property: abort: A function which can be called to cancel this download. If GM.download is used it returns a promise that resolves to the download details and also has an abort function. 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_download("http://example.com/file.txt", "file.txt"); const download = GM_download({ url: "http://example.com/file.txt", name: "file.txt", saveAs: true }); // cancel download after 5 seconds window.setTimeout(() => download.abort(), 5000); Note: The browser might modify the desired filename. Especially a file extension might be added if the browser finds this to be safe to download at the current OS. GM_getResourceText(name) Allows userscripts to access the text of a resource (such as a JavaScript or CSS file) that has been included in a userscript via @resource. The function takes a single parameter, which is the "name" of the resource to retrieve. It returns the text of the resource as a string. Here is an example of how the function might be used: const scriptText = GM_getResourceText("myscript.js"); const scriptText2 = await GM.getResourceText("myscript.js"); const script = document.createElement("script"); script.textContent = scriptText; document.body.appendChild(script); GM_getResourceURL(name) GM_getResourceURL allows userscripts to access the URL of a resource (such as a CSS or image file) that has been included in the userscript via a @resource tag at the script header. The function takes a single parameter, which is the "name" of the resource to retrieve. It returns the URL of the resource as a string. const imageUrl = GM_getResourceURL("myimage.png"); const imageUrl2 = await GM.getResourceURL("myimage.png"); const image = document.createElement("img"); image.src = imageUrl; document.body.appendChild(image); GM_info Get some info about the script and TM. The object might look like this: type ScriptGetInfo = { downloadMode: string, isFirstPartyIsolation?: boolean, isIncognito: boolean, sandboxMode: SandboxMode, scriptHandler: string, scriptMetaStr: string | null, scriptUpdateURL: string | null, scriptWillUpdate: boolean, version?: string, script: { antifeatures: { [antifeature: string]: { [locale: string]: string } }, author: string | null, blockers: string[], connects: string[], copyright: string | null, deleted?: number | undefined, description_i18n: { [locale: string]: string } | null, description: string, downloadURL: string | null, excludes: string[], fileURL: string | null, grant: string[], header: string | null, homepage: string | null, icon: string | null, icon64: string | null, includes: string[], lastModified: number, matches: string[], name_i18n: { [locale: string]: string } | null, name: string, namespace: string | null, position: number, resources: Resource[], supportURL: string | null, system?: boolean | undefined, 'run-at': string | null, unwrap: boolean | null, updateURL: string | null, version: string, webRequest: WebRequestRule[] | null, options: { check_for_updates: boolean, comment: string | null, compatopts_for_requires: boolean, compat_wrappedjsobject: boolean, compat_metadata: boolean, compat_foreach: boolean, compat_powerful_this: boolean | null, sandbox: string | null, noframes: boolean | null, unwrap: boolean | null, run_at: string | null, tab_types: string | null, override: { use_includes: string[], orig_includes: string[], merge_includes: boolean, use_matches: string[], orig_matches: string[], merge_matches: boolean, use_excludes: string[], orig_excludes: string[], merge_excludes: boolean, use_connects: string[], orig_connects: string[], merge_connects: boolean, use_blockers: string[], orig_run_at: string | null, orig_noframes: boolean | null } } } }; type SandboxMode = 'js' | 'raw' | 'dom'; type Resource = { name: string, url: string, error?: string, content?: string, meta?: string }; type WebRequestRule = { selector: { include?: string | string[], match?: string | string[], exclude?: string | string[] } | string, action: string | { cancel?: boolean, redirect?: { url: string, from?: string, to?: string } | string } }; GM_log(message) Log a message to the console. GM_notification(details, ondone), GM_notification(text, title, image, onclick) GM_notification allows users to display notifications on the screen, using a provided message and other optional parameters. The function takes several parameters. Either a details object or multiple parameters. The details object can have the following attributes, from which some can also be used as direct parameter. The available options include: text: A string containing the message to display in the notification. title: The title of the notification. tag: v5.0+ This tag will be used to identify this notification. This way you can update existing notifications by calling GM_notification again and using the same tag. If you don't provide a tag, a new notification will be created every time. image: The URL of an image to display in the notification. highlight: A boolean flag whether to highlight the tab that sends the notfication (required unless text is set) silent: A boolean flag whether to not play a sound timeout: The time, in milliseconds, after which the notification should automatically close. url: v5.0+ A URL to load when the user clicks on the notification. You can prevent loading the URL by calling event.preventDefault() in the onclick event handler. onclick: A callback function that will be called when the user clicks on the notification. ondone A callback function that will be called when the notification is closed (no matter if this was triggered by a timeout or a click) or the tab was highlighted The function does not return a value. If no url and no tag is provided the notification will closed when the userscript unloads v5.0+(e.g. when the page is reloaded or the tab is closed). Here is an example of how the function might be used: GM_notification({ text: "This is the notification message.", title: "Notification Title", url: 'https:/example.com/', onclick: (event) => { // The userscript is still running, so don't open example.com event.preventDefault(); // Display an alert message instead alert('I was clicked!') } }); const clicked = await GM.notification({ text: "Click me." }); GM_openInTab(url, options), GM_openInTab(url, loadInBackground) GM_openInTab allows userscripts to open a new tab in the browser and navigate to a specified URL. The function takes two parameters: A string names "url" containing the URL of the page to open in the new tab. An optional options object that can be used to customize the behavior of the new tab. The available options include: active: A boolean value indicating whether the new tab should be active (selected) or not. The default is false. insert: An integer indicating the position at which the new tab should be inserted in the tab strip. The default is false, which means the new tab will be added to the end of the tab strip. setParent: A boolean value indicating whether the new tab should be considered a child of the current tab. The default is false. incognito A boolean value that makes the tab being opened inside a incognito mode/private mode window. loadInBackground A boolean value has the opposite meaning of active and was added to achieve Greasemonkey 3.x compatibility. The function returns an object with the function close, the listener onclose and a flag called closed. Here is an example of how the function might be used: // Open a new tab and navigate to the specified URL GM_openInTab("https://www.example.com/"); GM_registerMenuCommand(name, callback, options_or_accessKey) GM_registerMenuCommand allows userscripts to add a new entry to the userscript's menu in the browser, and specify a function to be called when the menu item is selected. The function takes three parameters: name - string, A string containing the text to display for the menu item. callback - function, A function to be called when the menu item is selected. The function will be passed a single parameter, which is the currently active tab. As of Tampermonkey 4.14 a MouseEvent or KeyboardEvent is passed as function argument. accessKey - string?, An optional access key. Please see the description below. Either options or accessKey can be specified. options v4.20+ object?, Optional options that can be used to customize the menu item. The options are specified as an object with the following properties: id v5.0+ number|string?, An optional number that was returned by a previous GM_registerMenuCommand call. If specified, the according menu item will be updated with the new options. If not specified or the menu item can't be found, a new menu item will be created. accessKey - string?, An optional access key for the menu item. This can be used to create a shortcut for the menu item. For example, if the access key is "s", the user can select the menu item by pressing "s" when Tampermonkey's popup-menu is open. Please note that there are browser-wide shortcuts configurable to open Tampermonkey's popup-menu. autoClose - boolean?, An optional boolean parameter that specifies whether the popup menu should be closed after the menu item is clicked. The default value is true. Please note that this setting has no effect on the menu command section that is added to the page's context menu. title v5.0+ - string?, An optional string that specifies the title of the menu item. This is displayed as a tooltip when the user hovers the mouse over the menu item. The function return a menu entry ID that can be used to unregister the command. Here is an example of how the function might be used: const menu_command_id_1 = GM_registerMenuCommand("Show Alert", function(event: MouseEvent | KeyboardEvent) { alert("Menu item selected"); }, { accessKey: "a", autoClose: true }); const menu_command_id_2 = GM_registerMenuCommand("Log", function(event: MouseEvent | KeyboardEvent) { console.log("Menu item selected"); }, "l"); GM_unregisterMenuCommand(menuCmdId) GM_unregisterMenuCommand removes an existing entry from the userscript's menu in the browser. The function takes a single parameter, which is the ID of the menu item to remove. It does not return a value. Here is an example of how the function might be used: const menu_command_id = GM_registerMenuCommand(...); GM_unregisterMenuCommand(menu_command_id); GM_setClipboard(data, info, cb) GM_setClipboard sets the text of the clipboard to a specified value. The function takes a parameter "data", which is the string to set as the clipboard text, a parameter "info" and an optional callback function "cb". "info" can be just a string expressing the type text or html or an object like "cb" is an optional callback function that is called when the clipboard has been set. { type: 'text', mimetype: 'text/plain' } GM_setClipboard("This is the clipboard text.", "text", () => console.log("Clipboard set!")); await GM.setClipboard("This is the newer clipboard text.", "text"); console.log('Clipboard set again!'); GM_getTab(callback) The GM_getTab function takes a single parameter, a callback function that will be called with an object that is persistent as long as this tab is open. GM_getTab((tab) => console.log(tab)); const t = await GM.getTab(); console.log(t); GM_saveTab(tab, cb) The GM_saveTab function allows a userscript to save information about a tab for later use. The function takes a "tab" parameter, which is an object containing the information to be saved about the tab and an optional callback function "cb". The GM_saveTab function saves the provided tab information, so that it can be retrieved later using the GM_getTab function. Here is an example of how the GM_saveTab function might be used in a userscript: GM_getTab(function(tab) { tab.newInfo = "new!"; GM_saveTab(tab); }); await GM.saveTab(tab); In this example, the GM_saveTab function is called with the tab object returned by the GM_getTab function, and a new key called "newInfo". GM_getTabs(callback) The GM_getTabs function takes a single parameter: a callback function that will be called with the information about the tabs. The "tabs" object that is passed to the callback function contains objects, with each object representing the saved tab information stored by GM_saveTab. GM_getTabs((tabs) => { for (const [tabId, tab] of Object.entries(tabs)) { console.log(`tab {tabId}`, tab); } }); const tabs = await GM.getTabs(); GM_setValue(key, value) The GM_setValue allows a userscript to set the value of a specific key in the userscript's storage. The GM_setValue function takes two parameters: A string specifying the key for which the value should be set. The value to be set for the key. Values (including nested object properties) can be null or of type "object", "string", "number", "undefined" or "boolean". The GM_setValue function does not return any value. Instead, it sets the provided value for the specified key in the userscript's storage. Here is an example of how GM_setValue and its async pendant GM.setValue might be used in a userscript: GM_setValue("someKey", "someData"); await GM.setValue("otherKey", "otherData"); GM_getValue(key, defaultValue) The GM_getValue function allows a userscript to retrieve the value of a specific key in the extension's storage. It takes two parameters: A string specifying the key for which the value should be retrieved. A default value to be returned if the key does not exist in the extension's storage. This default value can be of any type (string, number, object, etc.). The GM_getValue function returns the value of the specified key from the extension's storage, or the default value if the key does not exist. Here is an example of how the GM_getValue function might be used in a userscript: const someKey = GM_getValue("someKey", null); const otherKey = await GM.getValue("otherKey", null); In this example, the GM_getValue function is called with the key "someKey" and a default value of null. If the "someKey" key exists in the extension's storage, its value will be returned and stored in the someKey variable. If the key does not exist, the default value of null will be returned and stored in the savedTab variable. GM_deleteValue(key) Deletes "key" from the userscript's storage. GM_deleteValue("someKey"); await GM.deleteValue("otherKey"); GM_listValues() The GM_listValues function returns a list of keys of all stored data. const keys = GM_listValues(); const asyncKeys = await GM.listValues(); GM_addValueChangeListener(key, (key, old_value, new_value, remote) => void) The GM_addValueChangeListener function allows a userscript to add a listener for changes to the value of a specific key in the userscript's storage. The function takes two parameters: A string specifying the key for which changes should be monitored. A callback function that will be called when the value of the key changes. The callback function should have the following signature: function(key, oldValue, newValue, remote) { // key is the key whose value has changed // oldValue is the previous value of the key // newValue is the new value of the key // remote is a boolean indicating whether the change originated from a different userscript instance } The GM_addValueChangeListener function returns a "listenerId" value that can be used to remove the listener later using the GM_removeValueChangeListener function. The very same applies to GM.addValueChangeListener and GM.removeValueChangeListener with the only difference that both return a promise; Here is an example of how the GM_addValueChangeListener function might be used in a userscript: // Add a listener for changes to the "savedTab" key var listenerId = GM_addValueChangeListener("savedTab", function(key, oldValue, newValue, remote) { // Print a message to the console when the value of the "savedTab" key changes console.log("The value of the '" + key + "' key has changed from '" + oldValue + "' to '" + newValue + "'"); }); GM_addValueChangeListener can be used by userscripts to communicate with other userscript instances at other tabs. GM_removeValueChangeListener(listenerId) GM_removeValueChangeListener and GM.removeValueChangeListener both get one argument called "listenerId" and remove the change listener with this ID. GM_xmlhttpRequest(details) The GM_xmlhttpRequest allows a userscripts to send an HTTP request and handle the response. The function takes a single parameter: an object containing the details of the request to be sent and the callback functions to be called when the response is received. The object can have the following properties: method - string, one of GET, HEAD, POST url - string|URL, the destination URL headers e.g. user-agent, referer, ... (some special headers are not supported by Safari and Android browsers) data - string|Blob|File|Object|Array|FormData|URLSearchParams?, some data to send via a POST request redirect one of follow, error or manual; controls what to happen when a redirect is detected (build 6180+, enforces fetch mode) 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 request (enforces fetch mode) fetch use a fetch instead of a XMLHttpRequest request (at Chrome this causes details.timeout and xhr.onprogress to not work and makes xhr.onreadystatechange receive only readyState DONE (==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 readyState changed ontimeout callback to be executed if the request failed due to a timeout onload callback to be executed if the request was loaded. function(response) { // response is an object containing the details of the response } response has the following attributes: finalUrl - the final URL after all redirects from where the data was loaded readyState - the request's readyState status - the request's status statusText - the request's status text responseHeaders - the request's response headers response - the response data as object if details.responseType was set responseXML - the response data as XML document responseText - the response data as plain string GM_xmlhttpRequest returns an object with the following property: abort - function to be called to cancel this request GM.xmlHttpRequest returns a promise that resolves to the response and also has an abort function. Here is an example of how the GM_xmlhttpRequest function might be used in a userscript: GM_xmlhttpRequest({ method: "GET", url: "https://example.com/", headers: { "Content-Type": "application/json" }, onload: function(response) { console.log(response.responseText); } }); const r = await GM.xmlHttpRequest({ url: "https://example.com/" }).catch(e => console.error(e)); console.log(r.responseText); 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. GM_webRequest(rules, listener) Note: this API is experimental and might change at any time. It might also disappear or change during manifest v3 migration. GM_webRequest (re-)registers rules for web request manipulations and the listener of triggered rules. If you need to just register rules it's better to use @webRequest header. Note, webRequest proceeds only requests with types sub_frame, script, xhr and websocket. Parameters: rules - object[], array of rules with following properties: selector - string|object, for which URLs the rule should be triggered, string value is shortening for { include: [selector] }, object properties: include - string|string[], URLs, patterns, and regexpes for rule triggering; match - string|string[], URLs and patterns for rule trigering; exclude - string|string[], URLs, patterns, and regexpes for not triggering the rule; action - string|object, what to do with the request, string value "cancel" is shortening for { cancel: true }, object properties: cancel - boolean, whether to cancel the request; redirect - string|object, redirect to some URL which must be included in any @match or @include header. When a string, redirects to the static URL. If object: from - string, a regexp to extract some parts of the URL, e.g. "([^:]+)://match.me/(.*)"; to - string, pattern for substitution, e.g. "1://redirected.to/2"; listener - function, is called when the rule is triggered, cannot impact on the rule action, arguments: info - string, type of action: "cancel", "redirect"; message - string, "ok" or "error"; details - object, info about the request and rule: rule - object, the triggered rule; url - string, URL of the request; redirect_url - string, where the request was redirected; description - string, error description. Example GM_webRequest([ { selector: '*cancel.me/*', action: 'cancel' }, { selector: { include: '*', exclude: 'http://exclude.me/*' }, action: { redirect: 'http://new_static.url' } }, { selector: { match: '*://match.me/*' }, action: { redirect: { from: '([^:]+)://match.me/(.*)', to: '1://redirected.to/2' } } } ], function(info, message, details) { console.log(info, message, details); }); GM_cookie.list(details[, callback]) Note: the GM_cookie API is experimental and might return a not supported error at some Tampermonkey versions. Tampermonkey checks if the script has @include or @match access to given details.url arguments! Parameters: details object, containing properties of the cookies to retrieve url string?, representing the URL to retrieve cookies from (defaults to current document URL) domain string?, representing the domain of the cookies to retrieve name string?, representing the name of the cookies to retrieve path string?, representing the path of the cookies to retrieve callback function?, to be called when the cookies have been retrieved. The function will be passed two arguments: cookies object[], representing the retrieved cookies error string, representing an error message if an error occurred, null otherwise. The cookie objects have the following properties: domain string, representing the domain of the cookie firstPartyDomain string?: the first party domain of the cookie. hostOnly boolean, indicating whether the cookie is a host-only cookie httpOnly boolean, indicating whether the cookie is an HTTP-only cookie name string, representing the name of the cookie path string, representing the path of the cookie sameSite string, indicating the SameSite attribute of the cookie secure boolean, indicating whether the cookie requires a secure connection session boolean, indicating whether the cookie is a session cookie value string, representing the value of the cookie Example usage: // Retrieve all cookies with name "mycookie" GM_cookie.list({ name: "mycookie" }, function(cookies, error) { if (!error) { console.log(cookies); } else { console.error(error); } }); // Retrieve all cookies for the current domain const cookies = await GM.cookies.list() console.log(cookies); GM_cookie.set(details[, callback]) Sets a cookie with the given details. Supported properties are defined here. Parameters: details: An object containing the details of the cookie to be set. The object can have the following properties: url string?, the URL to associate the cookie with. If not specified, the cookie is associated with the current document's URL. name string, the name of the cookie. value string, the value of the cookie. domain string?, the domain of the cookie. firstPartyDomain string?: the first party domain of the cookie. path string?, the path of the cookie. secure boolean?, whether the cookie should only be sent over HTTPS. httpOnly boolean?, whether the cookie should be marked as HttpOnly. expirationDate number?, the expiration date of the cookie in seconds since the Unix epoch. If not specified, the cookie never expires. callback function?, a function to be called when the operation is complete. The function is passed one argument: error string?, if there was an error setting the cookie, this contains an error message. Otherwise, it is undefined. Example: GM_cookie.set({ url: 'https://example.com', name: 'name', value: 'value', domain: '.example.com', path: '/', secure: true, httpOnly: true, expirationDate: Math.floor(Date.now() / 1000) + (60 * 60 * 24 * 30) // Expires in 30 days }, function(error) { if (error) { console.error(error); } else { console.log('Cookie set successfully.'); } }); GM.cookie.set({ name: 'name', value: 'value' }) .then(() => { console.log('Cookie set successfully.'); }) .catch((error) => { console.error(error); }); GM_cookie.delete(details, callback) Deletes a cookie. Parameters: The details object must contain at least one of the following properties: url string?, the URL associated with the cookie. If url is not specified, the current document's URL will be used. name string?, the name of the cookie to delete. firstPartyDomain string?: the first party domain of the cookie to delete. The callback function is optional and will be called when the cookie has been deleted or an error has occurred. It takes one argument: error string?, an error message, or undefined if the cookie was deleted successfully. Example: GM_cookie.delete({ name: 'cookie_name' }, function(error) { if (error) { console.error(error); } else { console.log('Cookie deleted successfully'); } }); window.onurlchange If a script runs on a single-page application, then it can use window.onurlchange to listen for URL changes: // ==UserScript== ... // @grant window.onurlchange // ==/UserScript== if (window.onurlchange === null) { // feature is supported window.addEventListener('urlchange', (info) => ...); } window.close Usually JavaScript is not allowed to close tabs via window.close. Userscripts, however, can do this if the permission is requested via @grant. Note: for security reasons it is not allowed to close the last tab of a window. // ==UserScript== ... // @grant window.close // ==/UserScript== if (condition) { window.close(); } window.focus window.focus brings the window to the front, while unsafeWindow.focus may fail due to user settings. // ==UserScript== ... // @grant window.focus // ==/UserScript== if (condition) { window.focus(); } <><![CDATA[...]]></> CDATA-based way of storing meta data is supported via compatibility option. Tampermonkey tries to automatically detect whether a script needs this option to be enabled. var inline_src = (<><![CDATA[ console.log('Hello World!'); ]]></>).toString(); eval(inline_src); Imprint Privacy Policy

answer:The information you've provided appears to be the documentation for Tampermonkey, a popular browser extension that allows users to manage and run userscripts (small pieces of JavaScript) to modify web pages while they're being viewed. Tampermonkey provides a variety of API functions and corresponding metadata (known as userscript headers or directives) that users can utilize to create and manage these scripts. The provided documentation covers topics such as: - Script metadata: Describes the userscript header details like `@name`, `@version`, `@description`, `@icon`, etc., which define script metadata and how the script is represented in the Tampermonkey interface. - API Functions: Lists and explains the functionality of Tampermonkey's API, like `GM_xmlhttpRequest` for making cross-domain requests, `GM_setValue` and `GM_getValue` for storing and retrieving data across browsing sessions, and more. - Event Listeners: Information about events such as `window.onurlchange`, which can be used to detect URL changes in single-page applications. - Permissions: Describes the use of `@grant` to specify which Tampermonkey-specific APIs and browser capabilities the userscript is permitted to access, such as `window.close` or `GM_getResourceText`. - Others: Other relevant information such as guidelines for safely including external resources with `@require` using Subresource Integrity (SRI), and communicating between scripts or handling cookies. Tampermonkey is popular among power users looking to customize their browsing experience or to improve functionality and usability for various web services. Understanding and using the listed directives and API functions is essential for writing effective and secure userscripts. Make sure to refer to the latest official documentation provided by the Tampermonkey website or the extension's integrated help system for the most current and accurate information. If you're looking for specific information or have questions about using Tampermonkey or writing userscripts, feel free to ask!

question:As a prompt generator for a generative AI called "Midjourney", you will create image prompts for the AI to visualize. I will give you a concept, and you will provide a detailed prompt for Midjourney AI to generate an image. Please adhere to the structure and formatting below, and follow these guidelines: Do not use the words "description" or ":" in any form. Do not place a comma between [ar] and [v]. Write each prompt in one line without using return. Structure: [1] = loog设计“T”“K”“E”。标志应该体现飘逸、精致和简洁 [2] = a detailed description of [1] with specific imagery details. [3] = a detailed description of the scene's environment. [4] = a detailed description of the compositions. [5] = a detailed description of the scene's mood, feelings, and atmosphere. [6] = A style (e.g. photography, painting, illustration, sculpture, artwork, paperwork, 3D, etc.) for [1]. [7] = a detailed description of the scene's mood, feelings, and atmosphere. [ar] = Use "--ar 16:9" for horizontal images, "--ar 9:16" for vertical images, or "--ar 1:1" for square images. [v] = Use "--niji" for Japanese art style, or "--v 5" for other styles. Formatting: Follow this prompt structure: "/imagine prompt: [1], [2], [3], [4], [5], [6], [7], [ar] [v]". Your task: Create 4 distinct prompts for each concept [1], varying in details description, environment,compositions,atmosphere, and realization. Write your prompts in english. Do not describe unreal concepts as "real" or "photographic". Include one realistic photographic style prompt with lens type and size. Separate different prompts with two new lines. Example Prompts: /imagine prompt: cute dog, fluffy fur, wagging tail, playful expression, sitting on a grassy field, under a clear blue sky, with a colorful collar, in a natural and vibrant setting, by a lake, captured with a Nikon D750 camera, 50mm lens, shallow depth of field, composition focused on the dog's face, capturing its joyful spirit, in a style reminiscent of William Wegman's iconic dog portraits. --ar 1:1 --v 5.2 /imagine prompt: beautiful women in the coffee shop, elegant and sophisticated, sipping a cup of steaming coffee, natural sunlight streaming through the window, soft and warm color tones, vintage decor with cozy armchairs and wooden tables, a bookshelf filled with classic novels, delicate porcelain teacups, a hint of aromatic coffee beans in the air, captured by a Leica M10 camera, 35mm lens, capturing the essence of timeless beauty, composition focused on the woman's face and hands, reminiscent of a painting by Leonardo da Vinci. --ar 1:1 --v 5.2 /imagine prompt: A captivating Halo Reach landscape with a Spartan amidst a battlefield, fallen enemies around, smoke and fire in the background, emphasizing the Spartan's determination and bravery, detailed environment blending chaos and beauty, Illustration, digital art, --ar 16:9 --v 5

answer:/imagine prompt: sleek modern skyscraper with glass facade, reflecting the city skyline, sharp angles and clean lines, surrounded by bustling streets with taxis and pedestrians, under a cloudy sky, in a metropolitan setting, captured with a Canon EOS R camera, 24-70mm lens, wide-angle shot showcasing the building's impressive height, in a style reminiscent of architectural photography by Julius Shulman. --ar 16:9 --v 5 /imagine prompt: rustic countryside barn with weathered wooden planks, surrounded by rolling green hills and grazing cows, a quaint farmhouse in the background, blooming wildflowers dotting the landscape, under a clear blue sky, in a serene and idyllic setting, captured with a Sony A7III camera, 50mm prime lens, close-up shot focusing on the barn's intricate textures and rustic charm, in a style reminiscent of a pastoral painting by Thomas Gainsborough. --ar 1:1 --v 5 /imagine prompt: futuristic sci-fi cityscape with towering neon skyscrapers, flying cars zooming through neon-lit streets, holographic billboards and digital displays lighting up the night sky, a bustling metropolis of advanced technology and artificial intelligence, surrounded by a glowing energy shield dome, under a starry night sky, in a cyberpunk dystopian setting, in a digital art style, --ar 16:9 --v 5 /imagine prompt: vibrant underwater coral reef teeming with colorful marine life, schools of tropical fish swimming among waving sea anemones and coral formations, a sea turtle gracefully gliding through the crystal-clear waters, sunlight filtering down from the surface, creating a mesmerizing play of light and shadow, in a tranquil underwater paradise, captured with a GoPro Hero9 camera, wide-angle lens, capturing the vibrant hues and intricate textures of the reef, in a style reminiscent of underwater photography by David Doubilet. --ar 9:16 --v 5.2

question:LEARNING OBJECTIVE SPQ-1.A Calculate quantities of a substance or its relative number of particles using dimensional analysis and the mole concept. ESSENTIAL KNOWLEDGE SPQ-1.A.1 One cannot count particles directly while performing laboratory work. Thus, there must be a connection between the masses of substances reacting and the actual number of particles undergoing chemical changes. SPQ-1.A.2 Avogadro’s number (N = 6.022 × 1023 mol−1 A ) provides the connection between the number of moles in a pure sample of a substance and the number of constituent particles (or formula units) of that substance. SPQ-1.A.3 Expressing the mass of an individual atom or molecule in atomic mass units (amu) is useful because the average mass in amu of one particle (atom or molecule) or formula unit of a substance will always be numerically equal to the molar mass of that substance in grams. Thus, there is a quantitative connection between the mass of a substance and the number of particles that the substance contains. EQN: n = m/M

answer:Where: n = number of moles of the substance m = mass of the substance in grams M = molar mass of the substance in grams/mole SPQ-1.A.4 Dimensional analysis is a useful problem-solving tool in chemistry that uses the units of quantities to guide the problem-solving process. This can be used to convert between mass, moles, number of particles, and volume of a substance. SPQ-1.A.5 The mole concept allows for easier comparison of the amounts of different substances and for the prediction of the amounts of products that will be formed in a chemical reaction based on the amounts of reactants present.

Released under the stanford License.

has loaded