ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Copy selection on webpage as text with text hyperlink URL's and ASCIIart

<< < (6/8) > >>

4wd:
After a little fooling around with GreaseMonkey and some outright butchery of a few userscripts, I've come up with something guaranteed to turn any sane website into a masterpiece of confusion.

Using the AutoHK site you gave above as an example, you'll get:




--- Code: Javascript ---// ==UserScript==// @name          TextLink// @namespace     // @description   Append text link after clickable link// @include       http://*// @include       https://*// @exclude       http://192.168.0.*// ==/UserScript== var links, link;links = document.evaluate(   '//a[@href]',   document,   null,   XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,   null); var re_http  = new RegExp("^http.*:\/\/");var re_mail = new RegExp("^mailto:");var re_ftp = new RegExp("^ftp.*:\/\/");for (var i = 0; i < links.snapshotLength; i++) {   a = links.snapshotItem(i);    if(a.href.match(re_http)) {      newDiv = document.createElement('text');      a.parentNode.insertBefore(newDiv, a.nextSibling);      newDiv.innerHTML = "&nbsp;[" + a + "]";   }   if(a.href.match(re_mail)) {      newDiv = document.createElement('text');      a.parentNode.insertBefore(newDiv, a.nextSibling);      newDiv.innerHTML = "&nbsp;[" + a + "]";   }   if(a.href.match(re_ftp)) {      newDiv = document.createElement('text');      a.parentNode.insertBefore(newDiv, a.nextSibling);      newDiv.innerHTML = "&nbsp;[" + a + "]";   }}
Save as TextLink.user.js - unless you have another called that, in which case save it as something else and change the name on the @name line.  Then just drop it on the Firefox window, if GreaseMonkey is installed it should recognise and install it.

I've only tested it on a couple of sites and I have no idea if what I've done follows Good Programming Guidelines but hey, what do expect for 30 minutes of completely unintelligent, uneducated keyboard tapping.

I'd recommend you leave it disabled until you're on a site you want to copy text from, then enable it and refresh ;)

Nater:
This works!  Awesome :up: 

I hope others can find this useful.

I have tried it out and it works great.  The only improvement I can think of for it would be to also recognize email addresses that are linked, but I am happy the way it is! 

THANK YOU 4wd!!!!!

skwire:
Nice work, 4wd.  Well done.   :D

4wd:
This works!  Awesome :up: 
-Nater (March 30, 2011, 12:04 AM)
--- End quote ---

Thanks!

I have tried it out and it works great.  The only improvement I can think of for it would be to also recognize email addresses that are linked, but I am happy the way it is!
--- End quote ---

Stupid me, mailto addresses don't have // on the end, just edit it to change:

var re_mail = new RegExp("^mailto:\/\/");

to:

var re_mail = new RegExp("^mailto:");

and that should take care of it.

Nice work, 4wd.  Well done.   :D-skwire (March 30, 2011, 12:06 AM)
--- End quote ---

Well, I wouldn't call it exactly 'nice' since I don't know if Element type of 'text' actually exists, that was just a guess on my part.  When it worked I stopped looking for the 'legal' method  ;D

Thanks skwire.

skwire:
Well, I wouldn't call it exactly 'nice' since I don't know if Element type of 'text' actually exists, that was just a guess on my part.  When it worked I stopped looking for the 'legal' method-4wd (March 30, 2011, 12:16 AM)
--- End quote ---

Whenever the OP says, "This works!  Awesome  :up:," well, that's nice work.   :D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version