diff --git a/Linkify Ting b/Linkify Ting new file mode 100644 index 0000000..cd68bb2 --- /dev/null +++ b/Linkify Ting @@ -0,0 +1,103 @@ +// This script looks for any thing of the form +// [something not blank][a dot][something not blank], +// then matches that which comes after the dot - and possibly before a slash - +// with a list of know extensions, such as com, us, net etc. +// If it has such an extension, it is turned into a link. +// This way the script attempts to catch links like +// google.com and userscripts.org/tag/link. +// Because the script looks up extensions in a list, +// you might want to alter the list (lovligeEndelser) to fit your needs. +// +// The script is borrows a bit from the “Linkify Plus” script +// (especially the parent not a | head | etc - thing). And therefore the following +// +//- - - +// +// Loosely based on the Linkify script located at: +// http://downloads.mozdev.org/greasemonkey/linkify.user.js +// +// Originally written by Anthony Lieuallen of http://www.arantius.com/ +// Licensed for unlimited modification and redistribution as long as +// this notice is kept intact. +// +// If possible, please contact me regarding new features, bugfixes +// or changes that I could integrate into the existing code instead of +// creating a different script. Thank you +// +//- - - +// +// for my sake you may do what you want with the script, +// but you should keep the notice by Anthony Lieuallen +// +// adam +// +// ==UserScript== +// @name Linkify ting +// @namespace http://ergosum.frac.dk/user/ +// @description Turn plain text links into real clikable links. Attempts to catch links like google.com +// @include * +// @exclude http://*.google.*/* +// ==/UserScript== +try{ +//dk|com|net|org|se|no|nl|us|uk|de|it|nu|edu|info + +var regex = /\b(http:\/\/|shttp:\/\/){0,1}(\w(\w|-)+\.)+(dk|com|net|org|se|no|nl|us|uk|de|it|nu|edu|info)(\/\w*)*(\.\w{2,4}){0,1}(\?\w*|#\w*|&\w*)*\b/gi; + +var altText, tekst, muligtLink; + +var ikkeTilladteTags = ['a', 'head', 'script', 'style', 'textarea', 'title', 'option', 'pre', 'code'];//tags, hvor det der stÃ¥r inden i ikke skal være links +var path = "//text()[not(parent::" + ikkeTilladteTags.join(" or parent::") +")]"; + +altText = document.evaluate(path, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); + +for(var i=0;i 7){ + prefix = href.substring(0,7); + } + if(prefix.toLowerCase() != 'http://'){ + href = 'http://' + href; + } + + //skab vores link: + var a = document.createElement('a'); + a.setAttribute('href', href); //giv det en href + a.appendChild(document.createTextNode(link)); //linkteksten + span.appendChild(a); //sætter ind i span + + lastLastIndex = regex.lastIndex; + + } + + span.appendChild(document.createTextNode(muligtLink.substring(lastLastIndex))); //insæt det der kommer efter sidste hit + tekst.parentNode.replaceChild(span, tekst); + + } + + +} +} catch(e){alert(e);}