Skip to content

Instantly share code, notes, and snippets.

@apoorv74
apoorv74 / index.html
Created January 21, 2016 16:42
Indian Railway Interactive
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.districts {
fill: #ccc;
}
.state-borders {
fill: none;
@illusionfield
illusionfield / bookmarklet-syntax.js
Last active March 21, 2024 05:25
Translate Bookmarklets
/**
* Web browsers use URIs for the href attribute of the <a> tag and for bookmarks. The URI scheme, such as http:, file:, or ftp:, specifies the protocol and the format for the rest of the string.
* Browsers also implement a prefix javascript: that to a parser is just like any other URI.
* Internally, the browser sees that the specified protocol is javascript, treats the rest of the string as a JavaScript application which is then executed, and uses the resulting string as the new page.
*
* 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.
*/
@caseywatts
caseywatts / bookmarkleting.md
Last active May 2, 2024 03:04
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.