Last active
April 17, 2020 14:22
-
-
Save joelcarranza/7904787 to your computer and use it in GitHub Desktop.
bookmarklet template for Pinswift
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 template for Pinswift | |
// This can be copied into a bookmarklet maker like: | |
// http://chriszarate.github.io/bookmarkleter/ | |
// Or used with Gruber's script | |
// http://daringfireball.net/2007/03/javascript_bookmarklet_builder | |
var href = location.href; | |
var path = 'pinswift://x-callback-url/add'; | |
var param = { | |
url:href, | |
title:document.title, | |
// optional parameters | |
// description: "this is just text", | |
// tags: "foo,bar", | |
// private: "yes", | |
// toread: "yes", | |
// these x-callback-url parameters tell us what URL to open when we are done | |
// for Safari, we return to the URL we bookmarked | |
// for Chrome, use the URL scheme googlechrome:// | |
'x-success':href, | |
'x-cancel':href | |
}; | |
// construct a pinswift URL from path + param | |
var url = [path]; | |
var n = 0; | |
for(var p in param) { | |
if(param.hasOwnProperty(p)) { | |
url.push(n++ == 0 ? '?' : '&',p,'=',encodeURIComponent(param[p])); | |
} | |
} | |
// open pinswift URL | |
window.location = url.join(''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment