Last active
August 29, 2015 14:01
-
-
Save myfonj/8a4606d1a5161e6c543e to your computer and use it in GitHub Desktop.
Single page self-contained browser 'boorkamark apps' or keyword commands / bookmarklets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(a,u,c,s,e,d){s.src=a+e('%'+'s'!=u?u:d.location)+'&callback='+e(c);d.body.appendChild(s)})('//archive.org/wayback/available?url=','%s','(function(o){document.location.assign(o.archived_snapshots.closest.url)})',document.createElement('script'),encodeURIComponent,document) | |
/* | |
1) bookmark above URI | |
2) invoke to navigate to most recent archive.org snapshot | |
Tip: set some keyword to it, so you could just prefix current (broken) url with it to get | |
pics: | |
1) http://dl.dropbox.com/u/1571982/shots/resurrect-bookmarklet-setup.png | |
2) http://dl.dropbox.com/u/1571982/shots/resurrect-bookmarklet-usage.png | |
The trick | |
- some `//some/jsonp/api` accepts `callback` param | |
-- `callback` param is just plain string, expecting name of some function that is declared before | |
--- then the content of | |
`//some/jsonp/api?callback=foo` | |
will be | |
foo('some data') | |
-- but the string can as well be '(function(data){alert(data)})' | |
--- so resulting content of | |
`//some/jsonp/api?callback=(function(data){alert(data)})` | |
will be | |
(function(data){alert(data)})('some data') | |
what is anonmous function expression with immediate invocation (aka "closure") | |
- so the only thing that is up to bookmarklet is to create script, assign it SRC wit prpper parameter and append it to current pages body | |
<script src="//some/jsonp/api?callback=(function(data){alert(data)})&query=some+query"> with some encoding | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bookmarklet | |
(function() | |
{ var callback_name = 'google_define_callback' | |
; function callback | |
( responseObject | |
, statusCode | |
, message | |
){ // todo | |
; console.log( responseObject ) | |
} | |
; function trigger( text ) | |
{ c = window[callback_name] | |
; console.log(c) | |
; c.script = c.script || document.createElement('script') | |
; var text = window.getSelection().toString(); | |
; c.script.src = 'http://www.google.com/dictionary/json?callback=' + callback_name + '&sl=en&tl=en&q=' + encodeURIComponent(text) | |
; document.body.appendChild( c.script ) | |
} | |
; window.google_define_trigger = window.google_define_trigger || trigger | |
; window[callback_name] = window[callback_name] || callback | |
})() | |
//view-source:http://www.google.com/dictionary/json?callback=cbck&sl=en&tl=en&q=example | |
{ "query": "example" | |
, "sourceLanguage": "en" | |
, "targetLanguage": "en" | |
, "primaries": | |
[ { "type": "headword" | |
, "terms": | |
[ { "type": "text" | |
, "text": "ex·am·ple" | |
, "language": "en" | |
, "labels": | |
[ { "text": "Noun" | |
, "title": "Part-of-speech" | |
} | |
] | |
} | |
, { "type": "phonetic" | |
, "text": "/igˈzampəl/" | |
, "language": "und" | |
} | |
, { "type": "sound" | |
, "text": "http://www.gstatic.com/dictionary/static/sounds/de/0/example.mp3" | |
, "language": "und" | |
} | |
] | |
, "entries": | |
[ { "type": "related" | |
, "terms": | |
[ { "type": "text" | |
, "text": "examples" | |
, "language": "und" | |
, "labels": | |
[ { "text": "plural" | |
} | |
] | |
} | |
] | |
} | |
, { "type": "meaning" | |
, "terms": | |
[ { "type": "text" | |
, "text": "A thing characteristic of its kind or illustrating a general rule" | |
, "language": "en" | |
} | |
] | |
, "entries": | |
[ { "type": "example" | |
, "terms": | |
[ { "type": "text" | |
, "text": "it\x27s a good \x3cem\x3eexample\x3c/em\x3e of how European action can produce results" | |
, "language": "en" | |
} | |
] | |
} | |
, { "type": "example" | |
, "terms": | |
[ { "type": "text" | |
, "text": "some of these carpets are among the finest \x3cem\x3eexamples\x3c/em\x3e of the period" | |
, "language": "en" | |
} | |
] | |
} | |
] | |
} | |
, { "type": "meaning" | |
, "terms": | |
[ { "type": "text" | |
, "text": "A printed or written problem or exercise designed to illustrate a rule" | |
, "language": "en" | |
} | |
] | |
} | |
, { "type": "meaning" | |
, "terms": | |
[ { "type": "text" | |
, "text": "A person or thing regarded in terms of their fitness to be imitated or the likelihood of their being imitated" | |
, "language": "en" | |
} | |
] | |
, "entries": | |
[ { "type": "example" | |
, "terms": | |
[ { "type": "text" | |
, "text": "it is vitally important that parents should \x3cb\x3eset an \x3cem\x3eexample\x3c/em\x3e\x3c/b\x3e" | |
, "language": "en" | |
} | |
] | |
} | |
, { "type": "example" | |
, "terms": | |
[ { "type": "text" | |
, "text": "she \x3cb\x3efollowed\x3c/b\x3e her brother\x27s \x3cb\x3e\x3cem\x3eexample\x3c/em\x3e\x3c/b\x3e and deserted her family" | |
, "language": "en" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
, { "type": "headword" | |
, "terms": | |
[ { "type": "text" | |
, "text": "ex·am·ple" | |
, "language": "en" | |
, "labels": | |
[ { "text": "Verb" | |
, "title": "Part-of-speech" | |
} | |
] | |
} | |
, { "type": "phonetic" | |
, "text": "/igˈzampəl/" | |
, "language": "und" | |
} | |
, { "type": "sound" | |
, "text": "http://www.gstatic.com/dictionary/static/sounds/de/0/example.mp3" | |
, "language": "und" | |
} | |
] | |
, "entries": | |
[ { "type": "meaning" | |
, "terms": | |
[ { "type": "text" | |
, "text": "Be illustrated or exemplified" | |
, "language": "en" | |
} | |
] | |
, "entries": | |
[ { "type": "example" | |
, "terms": | |
[ { "type": "text" | |
, "text": "the extent of Allied naval support is exampled by the navigational specialists provided" | |
, "language": "en" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
}, 200, null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html;charset=utf-8,<title>img to base64 datauri</title><body contenteditable onmouseleave=r=(b=document.body).innerHTML.match(/data:[^"]+/gm);if(r)b.innerHTML=r.join('\n') style=white-space:pre>DROP IMAGES HERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html;charset=utf-8;base64,PCFET0NUWVBFIEhUTUw+PG1ldGEgY2hhcnNldD11dGYt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bCBzZWUgd2hhdCB5b3Ugc2VlCgk8bGk+V2l0aG91dCBjcmVhdGluZyBhbmQgcHVibGlzaGluZyBzb21lICc8aT5waHlzaWNhbDwvaT4nIGRvY3VtZW50IG9ubGluZQoJPGxpPlN1cHBvcnRzIFVURi04IOKdpOKdpOKdpAoJPGxpPldvcmtzIHdlbGwgaW4gYWxsIHJlY2VudCBicm93c2VycyDigKYgYnV0IElFIPCfkqkgKG5vIGRhdGE6IGRvY3VtZW50cyB0aGVyZSDimLkpCgk8bGk+U29tZSBVUkwgc2hvcnRlbmVycyBhY2NlcHQgaXQgc28gPGEgaHJlZj0iaHR0cDovL3Rpbnl1cmwuY29tL3NlbGZjb250YWluZWQtZWRpdGFibGUtZGF0YXVyaSI+PGI+4oCm8J+YijwvYj48L2E+Cgk8bGk+VG8gc2VuZCBqdXN0IHN0YXRpYyAodW5lZGl0YWJsZSkgdGV4dCByZW1vdmUgdGhpcyB0ZXh0YXJlYSBhbmQgb3RoZXIgcmVsYXRlZCBtdW1ibyBmcm9tIHNvdXJjZQoJPGxpPlVuZG8gLyByZWRvIHNhdmUgID09IGhpc3RvcnkgYmFjayAvIGZvcndhcmQKPC9vbD4= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment