Greasemonkey Safari



  • Info
  1. You can use userscripts on iOS Safari using the new Shortcuts utility (though it seems to be complicated) and a lot easier using the free Safari Snippets app. However, this approach does not load userscripts automatically, they have to be manually loaded on each page load.
  2. Firefox 中先安装 Greasemonkey扩展后,再安装脚本; Chrome 中先安装 tampermonkey后,再安装脚本; Safari 中先安装 后,再安装脚本. Edge 中先安装 tampermonkey后,再安装脚本. IE 尚不能使用。 2、安装脚本.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/8068-1-greasemonkey-emulation/code/1%20Greasemonkey%20Emulation.js?version=36732

Safari and Internet Explorer will run user scripts if you also install optional extensions. A 'Greasemonkey script' is a user script that was written for Greasemonkey (which runs in Firefox) and uses proprietary GM functions.

Ask a question, post a review, or report the script.
Ratings
000
Version
2.0.1c
Created
2015-02-14
Updated
2015-02-14
License
GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
In the uncommon situations where someone wants to run a userscript via one of the lesser-known methods other than Greasemonkey/Tampermonkey, one runs into trouble with scripts that were written to expect the availability of the Greasemonkey API GM_ functions. A few adept scripters have written emulation libraries for some of those functions. This is a copy of one of those libraries, which previously hadn't been posted on Greasyfork, with a few small modifications I made (added logging-only stubs for GM_setClipboard, GM_getResourceText, & GM_getResourceURL; commented out the outdated userscripts.org-based update code); the unmodified version is also available in this posting's history. In addition to the predecessors of this script mentioned in the author Lil Devil's notes below, the other similar libraries I found are: joeytwiddle's FallbackGMAPI (us-m, github) and arantius's Grant None Shim (us-m, github).
This script library was archived from http://userscripts-mirror.org/scripts/show/105153
Author: Lil Devil
Script Name: Greasemonkey Emulation
Last update Jun 20, 2011 — Installed 12,199 times.
Script Summary: Emulate the Greasemonkey GM_* functions for other browsers.
A 'user script' is a script that runs in your web browser to change, enhance, and alter the appearance and function on a given website. Firefox, Chrome, and Opera all support user scripts natively. Safari and Internet Explorer will run user scripts if you also install optional extensions.
A 'Greasemonkey script' is a user script that was written for Greasemonkey (which runs in Firefox) and uses proprietary GM_ functions. Most user scripts (about 60%) do not use any GM_ functions, and will happily run in any browser that supports user scripts.
Greasemonkey safari jacketThe remaining 40% of user scripts do use one or more GM_ functions, and if you want to run them in a browser other than Firefox, you need to use a Greasemonkey emulation script.
This emulation script is based on the Greasemonkey Emulation script by ale5000, which in turn was based on the Emulate GM functions script by TarquinWJ.
This emulation script will help make most Greasemonkey scripts work in the following browsers:
- Google Chrome 8 and newer, but you have to build an extension containing your Greasemonkey script and this emulation script.
- Safari 5 and newer, with NinjaKit. May also work with GreaseKit, but is untested.
- Opera 10 and newer
- Midori (untested, but the previous version worked, and my changes shouldn't have broken anything.)
In addition, this script will help make some Greasemonkey scripts work in the following browsers:
- Internet Explorer 8 and newer, with IEPro
This script will enable all GM_ functions in Internet Explorer, but IE does not support many basic JavaScript and DOM functions that many Greasemonkey scripts use, so some scripts will get errors and stop running. Scripts can be written to be compatible with IE, but many scripts written specifically for Greasemonkey will not work in IE without additional work. Please contact the original script author and ask him/her to make their script compatible with IE.
GM_ Functions
UserscriptThis emulation script emulates all of the following Greasemonkey functions:

Tampermonkey For Mac

Greasemonkey SafariGM_setValue
GM_getValue
GM_deleteValue
GM_listValues
- These functions use the best available of scriptStorage, localStorage, or cookies to save data.
GM_addStyle
- Works just like the Greasemonkey function.
GM_xmlhttpRequest
- Works just like the Greasemonkey function. To enable cross-origin requests in Opera, see the note below in the Opera section.
GM_log
- Works just like the Greasemonkey function. Logs a message to the console. If unable to find the console, uses an alert().
GM_openInTab
- Opens a new tab where possible, otherwise it opens a new window.
GM_registerMenuCommand
- Implements the 'User Script Commands' menu as a pop-up menu in the lower-right corner of the browser window. The menu can be opened by pressing Ctrl- or by clicking your mouse in the lower-right corner. After it is opened the first time, a small 'S' icon will remain visible.
ResortGM_renameMenuCommand - Usage: GM_renameMenuCommand( oldCaption, newCaption, newAccessKey);
- Replaces the text of a menu command.
Please refer to the Greasemonkey API reference for more information on each of these functions.
Browser Notes
Opera [outdated information; use Violentmonkey or Tampermonkey for Opera now]
Download the file, rename to aab-greasemonkey-emulation.js and put it in your Userscripts folder.
If you have another GM emulation script installed, such as aagmfunctions.js, you must remove it from the Userscripts folder.
To enable cross-domain GM_xmlhttpRequest, you must also install this script, however most Greasemonkey scripts do not need this.
In Opera 10.62 and newer, you should go to the opera:config page and set the 'User JS Storage Quota' to a non-zero value. I suggest 5120. This enables user scripts to store private, cross-domain settings like in Firefox. If this setting remains disabled, user scripts must use localStorage which is not cross-domain, and can be read by other scripts.
Internet Explorer [outdated information; use TrixIE WPF4.5 or GreasemonkIE now]
Download the file, rename to aab-greasemonkey-emulation.ieuser.js and use IE[7]Pro to install it.
Safari with NinjaKit [outdated information; use Tampermonkey for Safari now]
Download the file, rename to aab-greasemonkey-emulation.user.js and put it in your Userscripts folder.
Midori
Download the file, rename to aab-greasemonkey-emulation.user.js and put it in your Userscripts folder.
Google Chrome [outdated information; use Tampermonkey for Chrome now]
This is a bit more complex than the other browsers. You need to build an extension. But it's really not that difficult. The first time I did it, I had to figure out what I was doing, and it took about 15 minutes. Now I can create an extension in less than 5 minutes. With these instructions it shouldn't take you much longer. To do.
Release Notes
2.0
  • Extensive changes to GM_registerMenuCommand
    • Support multiple copies of the emulation script, such as when embedded in extensions. This is done by storing all menu information in the DOM instead of in internal arrays.
    • Menu hotspot is always available, but only shows icon and menu after dragover.
    • Changed hotkey to ctrl-
    • Support keyboard navigation (up arrow, down arrow, enter)
  • Changed GM_addStyle to add style in plain text for easier debugging of userscripts.
  • Changed GM_xmlhttpRequest to only log an error if there is not a proper 'onerror' handler.

Version: 2.0 [updated by clickhappier to 2.0.1c on 02-14-2015]
Greasemonkey
Original author(s)Aaron Boodman
Developer(s)Anthony Lieuallen, Johan Sundström,[1] 13 more[2]
Initial release28 March 2005; 16 years ago[3]
Stable release
Repository
Written inJavaScript, XUL, CSS
Operating systemCross-platform
Available inEnglish
TypeMozilla extension
LicenseMIT License
Websitewww.greasespot.net

Greasemonkey is a userscript manager made available as a Mozilla Firefoxextension. It enables users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser (also known as augmented browsing).

The changes made to the web pages are executed every time the page is viewed, making them effectively permanent for the user running the script.

Greasemonkey can be used for customizing page appearance, adding new functions to web pages (for example, embedding price comparisons within shopping sites), fixing rendering bugs, combining data from multiple web pages, and numerous other purposes.

History[edit]

The Greasemonkey project began 28 November 2004, written by Aaron Boodman.[4][5][6] Boodman was inspired to write Greasemonkey after looking at a Firefox extension designed to clean up the interface of AllMusic,[7] written by Adrian Holovaty, who later became a userscript developer. By May 2005, there were approximately 60 general and 115 site-specific userscripts distributed for Greasemonkey.[7] In July 2005, serious vulnerabilities were found in Greasemonkey by Mark Pilgrim,[8][9] and fixed in the 3.5 version of Greasemonkey.[10] During this time, a Greasemonkey compiler was also developed for converting a userscript into a standalone Firefox extension.[11] Greasemonkey was initially met with complaints by publishers for its ability to block ads.[12] However, this criticism shifted its focus to other addons starting with the 2006 release of Adblock Plus.

Userscripts.org[edit]

To accommodate the growing number of scripts, userscripts.org was founded by Britt Selvitelle and other members of the Greasemonkey community in late 2005. Userscripts.org was open sourced in 2007 but the site later moved away from this code base.[13] As the main script repository listed on Greasemonkey's official site, userscripts.org accumulated thousands of scripts per year.

In 2010, the last known admin Jesse Andrews posted that the site was in maintenance mode due to lack of time and asked for a new maintainer to volunteer.[14] Nevertheless, he remained the sole admin of the site until a discussion about install counts began on 1 April 2013.[15] Prior to this, many of the 'most popular scripts' as listed by the site had nominal install counts of zero. Over the following year spam scripts became more common, server downtime increased and the install count bug remained.[16] With no further communication by Andrews, userscript writers described the site as neglected and the official Greasemonkey site removed its front page link.[17][18] In response, script writers and other developers began working on the fork 'openuserjs.org',[19][20] and later greasyfork.org,[21] as an immediate replacement.[22]

In May 2014, userscripts.org became inaccessible on port 80, prompting users to access it on port 8080 instead.[16] In August 2014, the site was shut down completely. Most of its scripts were backed up to the static mirror userscripts-mirror.org where they can now be found.[16]

Technical details[edit]

Greasemonkey user scripts are written in JavaScript and manipulate the contents of a web page using the Document Object Model interface. Scripts are generally written to be either page-specific or domain-specific (applying to all pages within a domain) but may also be tagged to apply to all domains for global browser enhancements. Users of Greasemonkey can write or download scripts and save them to their own personal library. When users visit a website matching a script in their personal script library, Greasemonkey invokes the relevant scripts.

Greasemonkey scripts can modify a webpage in any way that JavaScript allows, with certain Greasemonkey security restrictions. Scripts can also access other web pages and web services via a non-domain-restrictedXMLHTTP request, allowing external content to be merged with the original page content.

Scripts are named somename.user.js, and Greasemonkey offers to install any such script when a URL ending in that suffix is requested. Greasemonkey scripts contain metadata which specifies the name of the script, a description, resources required by the script, a namespace URL used to differentiate identically named scripts, and URL patterns for which the script is intended to be invoked or not.

Writing a Greasemonkey script is similar to writing JavaScript for a web page, with some additional allowances such as cross-site XMLHttpRequests. Compared to writing a full-fledged Firefox extension, user scripting is a very modest step up in complexity from basic web programming. However, Greasemonkey scripts are limited due to security restrictions imposed by Mozilla's XPCNativeWrappers[23] For example, Greasemonkey scripts do not have access to many of Firefox's components, such as the download manager, I/O processes or its main toolbars. Additionally, Greasemonkey scripts run per instance of a matching webpage. Because of this, managing lists of items globally is difficult. However, script writers have been using cookies and Greasemonkey even offers APIs such as GM_getValue and GM_setValue to overcome this.

User scripts[edit]

Tampermonkey

File hosting servers for Greasemonkey require that the URLs for the scripts end with .user.js and not with a MIME type like text/html. Support for HTTPS will meet with[clarification needed] Greasemonkey's built in update checker. As of July 2019, the Greasemonkey project lists three recommended user script hostings:[24]

  • Gist, a pastebin service operated by GitHub where simple files are hosted. Files can be pasted into a web form and saved. HTTPS is used by default. Files may follow the naming scheme with the '.user.js' suffix for the URL serving as an install link.
  • Greasy Fork, a site created by the maintainer of userstyles.org.[21]
  • OpenUserJS.org, a site that started as a fork for the deprecated script repository userscripts.org.[19][20]

Compatibility[edit]

Greasemonkey is available for Firefox, Flock and GNOME Web (formerly called Epiphany). The Greasemonkey extension for Web is part of the Web extensions package. However, this extension is not fully compatible as of release 2.15.1, since some Greasemonkey API functions (e.g. GM_getValue) are unsupported. There are also custom versions for SeaMonkey,[25][26]Songbird,[27]Pale Moon,[28]qutebrowser[29] and Falkon browser.

See also[edit]

Userscripts Safari

References[edit]

  1. ^'The weblog about Greasemonkey'.
  2. ^'The greasemonkey network graph'.
  3. ^'Initial Greasemonkey Release'.
  4. ^'Greasemonkey Project Info'. Archived from the original on 25 March 2012. Retrieved 31 August 2011.
  5. ^Pilgrim, Mark (2005). Greasemonkey Hacks. O'Reilly. ISBN978-0-596-55357-9.
  6. ^'Aaron Boodman wrote Greasemonkey in 2004'.
  7. ^ abSingel, Ryan (17 May 2005). 'Firefox Users Monkey With the Web?'. Wired magazine.
  8. ^http://mozdev.org/pipermail/greasemonkey/2005-July/004033.html
  9. ^https://lwn.net/Articles/144452/
  10. ^http://mozdev.org/pipermail/greasemonkey/2005-July/004379.html
  11. ^Nivi (8 May 2005). 'Greasemonkey will blow up business models (as well as your mind)'. Archived from the original on 3 June 2006. Retrieved 22 July 2010.
  12. ^Festa, Paul (24 March 2005). 'Firefox add-on lets surfers tweak sites, but is it safe?'. CNET.
  13. ^Selvitelle, Britt (3 January 2007). 'Userscripts.org... Opensource!'. Archived from the original on 17 January 2007. Retrieved 21 May 2014.
  14. ^'Passing the torch on userscripts.org'. Hacker News. 2010. Retrieved 24 October 2014.
  15. ^'Fixing Install Counts'. 1 April 2013. Archived from the original on 3 November 2013. Retrieved 21 May 2014.
  16. ^ abcBrinkmann, Martin (9 May 2014). 'Userscripts.org down for good? Here are alternatives'. Retrieved 21 May 2014.
  17. ^'User Script Hosting'. 16 May 2014. Retrieved 21 May 2014.
  18. ^'Please change the official userscript site'. greasemonkey-dev (Mailing list). 21 April 2014. Retrieved 21 May 2014.
  19. ^ ab'OpenUserJS'. openuserjs.org.
  20. ^ ab'Fixing Install Counts – Page 6'. 1 April 2013. Archived from the original on 3 November 2013. Retrieved 5 November 2015.
  21. ^ ab'Greasy Fork'. greasyfork.org.
  22. ^Barnabe, Jason (19 February 2014). 'Introducing Greasy Fork – a user scripts site'. Retrieved 5 November 2015.
  23. ^.https://developer.mozilla.org/en/XPCNativeWrapper
  24. ^'User Script Hosting - GreaseSpot Wiki'. wiki.greasespot.net. Retrieved 22 July 2019.
  25. ^'Greasemonkey'. mozdev.org. mozdev. Retrieved 5 May 2009.
  26. ^'Greasemonkey Port for SeaMonkey - About - OpenUserJS'. openuserjs.org.
  27. ^ianloic. 'Greasemonkey'. Songbird. Archived from the original on 2 June 2008. Retrieved 5 May 2009.
  28. ^'janekptacijarabaci/greasemonkey'. GitHub. Retrieved 23 March 2020.
  29. ^'Improvements for GreaseMonkey support · Issue #3238 · qutebrowser/qutebrowser'. GitHub. Retrieved 19 May 2020.

External links[edit]

Media related to Greasemonkey at Wikimedia Commons

Retrieved from 'https://en.wikipedia.org/w/index.php?title=Greasemonkey&oldid=1018739297'