Greasemonkey Automation - sgml/signature GitHub Wiki

API Mapping

Greasemonkey Underlying Browser APIs

Storage

  • browser.storage.local
    Used for GM_getValue, GM_setValue, GM_deleteValue, GM_listValues.
    Provides persistent key/value storage for user scripts.

Networking

  • XMLHttpRequest
    Classic API used for GM_xmlhttpRequest.
    Allows cross-domain HTTP requests (predating fetch).
  • fetch (modern fallback)
    Sometimes used in newer implementations, but Greasemonkey historically wraps XMLHttpRequest.

DOM Injection

  • document.createElement, appendChild, insertBefore
    Used for GM_addStyle and script/style injection.
  • document.querySelector, document.getElementById
    Used for locating insertion points in the DOM.

Clipboard

  • navigator.clipboard.writeText
    Modern API used for GM_setClipboard.
  • document.execCommand("copy")
    Legacy fallback for clipboard operations.

Notifications

  • browser.notifications
    Used for GM_notification.
    Provides system-level notifications from extensions.

Tabs & Windows

  • browser.tabs.create
    Used for GM_openInTab.
    Opens new browser tabs programmatically.
  • browser.windows
    Used for window-level management when needed.

Menus

  • browser.contextMenus / browser.menus
    Used for GM_registerMenuCommand.
    Adds custom commands to the extension’s right-click menu.

Downloads

  • browser.downloads.download
    Used for GM_download.
    Provides file download functionality from user scripts.

Messaging

  • browser.runtime.sendMessage / browser.runtime.onMessage
    Used internally for communication between background scripts and content scripts.

Key Notes

  • Early Greasemonkey (pre-WebExtension) relied on Firefox XPCOM Components (nsIFile, nsIIOService, etc.).
  • Modern Greasemonkey (v4+) uses the WebExtensions API for cross-browser compatibility.
  • Tampermonkey and Violentmonkey follow the same model, often polyfilling with fetch, localStorage, or IndexedDB.

Summary

Greasemonkey’s GM_* functions are wrappers around stable browser APIs:

  • Storagebrowser.storage.local
  • NetworkingXMLHttpRequest / fetch
  • DOM Injection → Standard DOM methods
  • Clipboardnavigator.clipboard
  • Notificationsbrowser.notifications
  • Tabsbrowser.tabs
  • Menusbrowser.contextMenus
  • Downloadsbrowser.downloads
  • Messagingbrowser.runtime

These APIs are frozen and stable, ensuring long-term compatibility for user scripts.

Auto Pagination

function click1000(){
document.querySelector("#load_more").click()
}

var clickInterval = window.setInterval(click1000, 1000);

#Anti-Modal

$("div[name='trap-focus']").remove()
document.body.removeAttribute("style")

References

chrome://guerilla-script-dox/content/README.txt

https://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window

https://www.tampermonkey.net/documentation.php

https://violentmonkey.github.io/api/gm/

https://blog.mozilla.org/addons/2019/03/26/extensions-in-firefox-67/#userscripts

https://medium.com/snips-ai/how-to-block-third-party-scripts-with-a-few-lines-of-javascript-f0b08b9c4c0

https://designsystem.digital.gov/components/form-controls/

https://developer.chrome.com/extensions/migrating_to_manifest_v3

https://blog.mozilla.org/addons/2019/09/03/mozillas-manifest-v3-faq/

⚠️ **GitHub.com Fallback** ⚠️