Skip to content

Instantly share code, notes, and snippets.

@purtuga
Created June 4, 2018 14:46
Show Gist options
  • Save purtuga/a2bf5e692b5b87529feab7d49c49238a to your computer and use it in GitHub Desktop.
Save purtuga/a2bf5e692b5b87529feab7d49c49238a to your computer and use it in GitHub Desktop.
Post with Buffer by opening a new window to the buffer add page
(function(encodeURI, DOCUMENT){
var link = DOCUMENT.createElement("a");
link.href="https://buffer.com/add?text=" + encodeURI(DOCUMENT.title) + "&url=" + DOCUMENT.location;
link.setAttribute("style", "position:absolute;left=-99999px;top:-99999px;visibility:hidden");
link.setAttribute("target", "_blank");
DOCUMENT.body.appendChild(link);
link.click();
setTimeout(function(){link.parentNode.removeChild(link);}, 10);
})(encodeURIComponent, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment