Bookmarklet
Template:Short description Template:Use dmy dates
A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser. They are stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. Bookmarklets are usually small snippets of JavaScript executed when user clicks on them. When clicked, bookmarklets can perform a wide variety of operations, such as running a search query from selected text or extracting data from a table.
Another name for bookmarklet is favelet or favlet, derived from favorites (synonym of bookmark).[1]
History
Steve Kangas of bookmarklets.com coined the word bookmarklet[2] when he started to create short scripts based on a suggestion in Netscape's JavaScript guide.[3] Before that, Tantek Çelik called these scripts favelets and used that word as early as on 6 September 2001 (personal emailTemplate:Clarify). Brendan Eich, who developed JavaScript at Netscape, gave this account of the origin of bookmarklets:
The increased implementation of Content Security Policy (CSP) in websites has caused problems with bookmarklet execution and usage (2013–2015),[4] with some suggesting that this hails the end or death of bookmarklets.[5][6] William Donnelly created a work-around solution for this problem (in the specific instance of loading, referencing and using JavaScript library code) in early 2015 using a Greasemonkey userscript (Firefox / Pale Moon browser add-on extension) and a simple bookmarklet-userscript communication protocol.[7] It allows (library-based) bookmarklets to be executed on any and all websites, including those using CSP and having an https:// URI scheme. However, if/when browsers support disabling/disallowing inline script execution using CSP, and if/when websites begin to implement that feature, it will "break" this "fix".
Concept
Web browsers use URIs for the href attribute of the <a> tag and for bookmarks. The URI scheme, such as http or ftp, and which generally specifies the protocol, determines the format of the rest of the string. Browsers also implement javascript: URIs that to a parser is just like any other URI. The browser recognizes the specified javascript scheme and treats the rest of the string as a JavaScript program which is then executed. The expression result, if any, is treated as the HTML source code for a new page displayed in place of the original.
The executing script has access to the current page, which it may inspect and change. If the script returns an undefined type (rather than, for example, a string), the browser will not load a new page, with the result that the script simply runs against the current page content. This permits changes such as in-place font size and color changes without a page reload.
An immediately invoked function that returns no value or an expression preceded by the void operator will prevent the browser from attempting to parse the result of the evaluation as a snippet of HTML markup:
javascript:(function(){
//Statements returning a non-undefined type, e.g. assignments
})();
Usage
Template:Sister project Bookmarklets are saved and used as normal bookmarks. As such, they are simple "one-click" tools which add functionality to the browser. For example, they can:
- Modify the appearance of a web page within the browser (e.g., change font size, background color, etc.)
- Extract data from a web page (e.g., hyperlinks, images, text, etc.)
- Remove redirects from (e.g. Google) search results, to show the actual target URL[8]
- Submit the current page to a blogging service such as Posterous, link-shortening service such as bit.ly, or bookmarking service such as Delicious
- Query a search engine or online encyclopedia with highlighted text or by a dialog box
- Submit the current page to a link validation service or translation service
- Set commonly chosen configuration options when the page itself provides no way to do this
- Control HTML5 audio and video playback parameters such as speed, position, toggling looping, and showing/hiding playback controls, the first of which can be adjusted beyond HTML5 players' typical range setting.[9][10][11]
Installing a bookmarklet follows the same process as adding a normal bookmark; the only difference is that in place of the URL destination field is JavaScript code preceded by javascript:. Once created, bookmarklets can be run by clicking on them.
References
External links
- Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1". registered 9 April 1998
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".
- ↑ Script error: No such module "citation/CS1".