-
-
Save datygra/73b55dba1b360b2de62bbfd94c90f934 to your computer and use it in GitHub Desktop.
Create a bookmark and paste the code from `grab links.bookmarklet` into the url. Trigger it on a page containing links you want to save and then click the section of the page containing the links. A Markdown list of all links will be generated, and clicking the resulting list will select all for copying.
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(n,j,l,k,m,p,i,o){if(!(m=n.jQuery)||l>m.fn.jquery||k(m)){p=j.createElement("script");p.type="text/javascript";p.src="http://ajax.googleapis.com/ajax/libs/jquery/"+l+"/jquery.min.js";p.onload=p.onreadystatechange=function(){if(!i&&(!(o=this.readyState)||o=="loaded"||o=="complete")){k((m=n.jQuery).noConflict(1),i=1);m(p).remove()}};j.documentElement.childNodes[0].appendChild(p)}})(window,document,"1.7",function(b,a){b(document).ready(function(){var c=function(){var g=document,h=g.getElementById("linkoutput"),e,f;if(g.body.createTextRange){e=g.body.createTextRange();e.moveToElementText(h);e.select()}else{if(window.getSelection){f=window.getSelection();e=g.createRange();e.selectNodeContents(h);f.removeAllRanges();f.addRange(e)}}},d=[];b("div,table,article,section,aside").on("mouseover mouseout click",function(e){e.type==="mouseover"?b(this).css({outline:"1px solid red",padding:"+10px"}):b("div,table,article,section,aside").css({outline:"none",padding:"-10px"});if(e.type==="click"){e.preventDefault();var f,g=b(this).find("a");g.each(function(j,k){var l=b(k).text()===undefined?b(k).attr("href"):b(k).text().replace(/[\n\r\s]+/g," ").replace(/(^\s*|\s*$)/g,"").slice(0,100);var h=/^http/.test(b(k).attr("href"))?b(k).attr("href"):document.location.protocol+"//"+document.location.hostname+b(k).attr("href");d.push(["- ["+l.replace(/[\[\]\|]+/g,"")+"]("+h+")"])});b("<div>").css({position:"fixed",top:"0",left:"0",right:"0",bottom:"0",overflow:"auto",backgroundColor:"#efefef",color:"#333",zIndex:"99999"}).append(b("<pre id=linkoutput>").css({padding:"20px",margin:"40px"}).text(d.join("\n")).click(function(){c()})).click(function(h){if(h.target.tagName=="DIV"){b(this).remove();b("div,table,article,section,aside").unbind()}}).appendTo("body");c();return false}})})}); |
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(e, a, g, h, f, c, b, d) { | |
| if (!(f = e.jQuery) || g > f.fn.jquery || h(f)) { | |
| c = a.createElement("script"); | |
| c.type = "text/javascript"; | |
| c.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + g + "/jquery.min.js"; | |
| c.onload = c.onreadystatechange = function() { | |
| if (!b && (!(d = this.readyState) || d == "loaded" || d == "complete")) { | |
| h((f = e.jQuery).noConflict(1), b = 1); | |
| f(c).remove() | |
| } | |
| }; | |
| a.documentElement.childNodes[0].appendChild(c) | |
| } | |
| })(window, document, "1.7", function($, L) { | |
| $(document).ready(function() { | |
| var selectLinks = function() { | |
| var doc = document, | |
| text = doc.getElementById("linkoutput"), | |
| range, selection; | |
| if (doc.body.createTextRange) { | |
| range = doc.body.createTextRange(); | |
| range.moveToElementText(text); | |
| range.select(); | |
| } else if (window.getSelection) { | |
| selection = window.getSelection(); | |
| range = doc.createRange(); | |
| range.selectNodeContents(text); | |
| selection.removeAllRanges(); | |
| selection.addRange(range); | |
| } | |
| }, collection = []; | |
| $("div,table,article,section,aside").on("mouseover mouseout click", function(a) { | |
| a.type === "mouseover" ? $(this).css({ | |
| outline: "1px solid red", | |
| padding:"+10px" | |
| }) : $("div,table,article,section,aside").css({ | |
| outline: "none", | |
| padding:"-10px" | |
| }); | |
| if (a.type === "click") { | |
| a.preventDefault(); | |
| var i, linkage = $(this).find("a"); | |
| linkage.each(function(i, link) { | |
| var linktext = $(link).text() === undefined ? $(link).attr("href") : $(link).text().replace(/[\n\r\s]+/g, " ").replace(/(^\s*|\s*$)/g, "").slice(0, 100); | |
| var url = /^http/.test($(link).attr("href")) ? $(link).attr("href") : document.location.protocol + "//" + document.location.hostname + $(link).attr("href"); | |
| collection.push(["- [" + linktext.replace(/[\[\]\|]+/g, "") + "](" + url + ")"]); | |
| }); | |
| $("<div>").css({ | |
| position: "fixed", | |
| top: "0", | |
| left: "0", | |
| right: "0", | |
| bottom: "0", | |
| overflow: "auto", | |
| backgroundColor: "#efefef", | |
| color: "#333", | |
| zIndex: "99999" | |
| }).append($("<pre id=linkoutput>").css({padding: "20px", margin: "40px"}).text(collection.join("\n")).click(function(){ | |
| selectLinks(); | |
| })).click(function(ev){ | |
| if (ev.target.tagName == "DIV") { | |
| $(this).remove(); | |
| $("div,table,article,section,aside").unbind(); | |
| } | |
| }).appendTo("body"); | |
| selectLinks(); | |
| return false; | |
| } | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment