Hello! I'm writing bookmarklet right now which sends the links from selection to external server. I don't know how to write part responsible for extract links from selection. For instance, i need:
1) Recognizing links in selection written in plain text, for example:
2) Recognizing links in selection written in html, for example:Code:http://www.x.com/dddffsfds/fsdfdsfdsfds http://www.x.com/dddffsfds/fsdfdsfdsfds http://www.x.com/dddffsfds/fsdfdsfdsfds http://www.x.com/dddffsfds/fsdfdsfdsfds http://www.x.com/dddffsfds/fsdfdsfdsfds
How I can handle this both methods simultaneously? Any idea? That's is my current code:Code:<a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>CLUTTER<a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>CLUTTER<a href="http://www.x.com/dddffsfds/fsdfdsfdsfds">CLUTTER - IGNORE IF HERE IS ALSO http://(...) and so on</a>
Code:// Helper - remove duplicates from array. Array.prototype.unique = function () { var r = new Array(); o:for(var i = 0, n = this.length; i < n; i++) { for(var x = 0, y = r.length; x < y; x++) { if(r[x]==this[i]) { continue o; } } r[r.length] = this[i]; } return r; } // We are getting selection selection = ??????????? // We are looking for links in selection and make array from they files = ??????????????? if (files.length < 1) { unique = files.unique(); urls = unique.join('|'); location.href 'http://x/imports/new?from=bookmarklet&urls=' + urls } else { alert('There is no any links in selection.'); }


Reply With Quote
Bookmarks