- Right click on bookmark bar (ctrl+shirt+b to disply if hidden)
- Click "Add Page..."
- Change Name to "Tweet Highlight"
- Change URL to the string of text found in TweetHighlight.bm
- Click Save
Last active
December 22, 2020 19:32
-
-
Save mcwhittemore/4431121 to your computer and use it in GitHub Desktop.
Bookmarklet to let you post highlighted text to twitter. Slightly moded version of http://jsfiddle.net/dKaJ3/2/. Encoded via http://chris.zarate.org/bookmarkleter.
This file contains hidden or 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
function getSelectionHtml() { | |
var html = ""; | |
if (typeof window.getSelection != "undefined") { | |
var sel = window.getSelection(); | |
if (sel.rangeCount) { | |
var container = document.createElement("div"); | |
for (var i = 0, len = sel.rangeCount; i < len; ++i) { | |
container.appendChild(sel.getRangeAt(i).cloneContents()); | |
} | |
html = container.innerHTML; | |
} | |
} else if (typeof document.selection != "undefined") { | |
if (document.selection.type == "Text") { | |
html = document.selection.createRange().htmlText; | |
} | |
} | |
var url='https://twitter.com/intent/tweet%3Fsource=highlight%26text='+html+' '+window.location.href; | |
window.open(url,'_blank'); | |
} | |
getSelectionHtml(); |
This file contains hidden or 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(){function%20getSelectionHtml(){var%20html=%22%22;if(typeof%20window.getSelection%20!=%22undefined%22){var%20sel=window.getSelection();if(sel.rangeCount){var%20container=document.createElement(%22div%22);for(var%20i=0,len=sel.rangeCount;i%20%3C%20len;++i){container.appendChild(sel.getRangeAt(i).cloneContents());}html=container.innerHTML;}}else%20if(typeof%20document.selection%20!=%22undefined%22){if(document.selection.type==%22Text%22){html=document.selection.createRange().htmlText;}}var%20url='https://twitter.com/intent/tweet%3Fsource=highlight%26text='+html+'%20'+window.location.href;window.open(url,'_blank');}getSelectionHtml();})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!