Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created June 29, 2021 13:04
Show Gist options
  • Save ttscoff/bf81904e4c719b912e77014f865bbee8 to your computer and use it in GitHub Desktop.
Save ttscoff/bf81904e4c719b912e77014f865bbee8 to your computer and use it in GitHub Desktop.
Bookmarklet for Pins.app (1.6+)
// Bookmarklet for [Pins.app](https://get-pins.app/) (requires version 1.6+)
// Removes Google Analytics strings
// Removes Product Hunt query string
// Prefers canonical url if defined
// Uses selected text for description, falling back to meta description
// Removes pipes (|) from title
// To allow use on any website in Firefox, go to about:config and set security.external_protocol_requires_permission to false
// Copy this to your URL bar:
javascript:!function(){function e(e){var n="pins://launch?screen=newPost&",i=o();""===i&&(i=r()),n+="url="+encodeURIComponent(e),n+="&",n+="title="+encodeURIComponent(t()),n+="&",n+="description="+encodeURIComponent(i),document.location.href=n}function t(){var e=document.title;return e.replace(/\|/g,"-")}function n(){for(var e=document.getElementsByTagName("link"),t=0;t<e.length;t++)if(e[t].attributes.hasOwnProperty("rel")&&"canonical"===e[t].attributes.rel.textContent.toLowerCase())return e[t].attributes.href.textContent;var n,o=document.location.href.split(/[?&]([^&]+)/gim).filter(i);return n=o.length>1?o[0]+"?"+o.slice(1,-1).join("&"):o[0]}function o(){var e;if(window.getSelection)e=window.getSelection();else if(document.getSelection)e=document.getSelection();else{if(!document.selection)return;e=document.selection.createRange().text}return e.toString()}function r(){for(var e=document.getElementsByTagName("meta"),t=0;t<e.length;t++)if("description"===e[t].name.toLowerCase())return e[t].content;return""}function i(e){return!e.match(/(utm_[^&]+|ref=producthunt|^$)/)}e(n())}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment