-
IT café
Új hozzászólás Aktív témák
-
hack69
aktív tag
válasz fatal` #11885 üzenetére
// ==UserScript==
// @name Linkify html files (9+)
// @author Jan Martin Pettersen
// @description Makes text http/https/ftp URLs clickable (for version 9.0+).
// @namespace http://userjs.org/
// @version 1.0.0
// @include *
// ==/UserScript==
/*
* Copyright © 2006 by Jan Martin Pettersen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
/*
All global variables and functions is prefixed with hd_zzzzzz_ to avoid
conflicts.
*/
//var hd_zzzzzz_urlRegex = /\b(((https?|ftp|irc|rtsp|mms[tu]?|unsv|uvox|icy|shout|scp?|sftp|gopher|nntp|telnet|tn3270|msbd|file|s?news):\/\/|(mailto|s?news|data):)[^\s\"<>\{\}\'\(\)]*)/g;
//^^^The above line has many protocols defined. Make sure you comment the lines you won't be using.
var hd_zzzzzz_urlRegex = /\b(((https?|ftp|irc|file|s?news):\/\/|(mailto|s?news):)[^\s\"<>\{\}\'\(\)]*)/g;
//^^^Medium version
//var hd_zzzzzz_urlRegex = /\b(((https?):\/\/)[^\s\"<>\{\}\'\(\)]*)/g;
//^^^Small version
//Set this to a class name if you want it to use a style from a stylesheet.
var hd_zzzzzz_linkClass='';
var hd_zzzzzz_preCreatedA=null;
function hd_zzzzzz_LinkifyNode(node,mydoc){
var i,tmpData,foundPos,matchedText,middleText,endText,v;
var newLinkElement,linkTextNode,skip=0;
if(node){
if (node.data){
tmpData=node.data;
foundPos=tmpData.search(hd_zzzzzz_urlRegex);
if (foundPos>=0){
matchedText=RegExp.$1;
middleText=node.splitText(foundPos);
middleText.deleteData(0,matchedText.length);
if (hd_zzzzzz_preCreatedA){
newLinkElement=hd_zzzzzz_preCreatedA.cloneNode(false);
} else{
newLinkElement=mydoc.createElement('a');
newLinkElement.setAttribute('target','_blank');
if (hd_zzzzzz_linkClass!=''){
newLinkElement.setAttribute('class',hd_zzzzzz_linkClass);
}
hd_zzzzzz_preCreatedA=newLinkElement.cloneNode(false);
}
newLinkElement.setAttribute('href',matchedText);
linkTextNode=mydoc.createTextNode(matchedText);
newLinkElement.appendChild(linkTextNode);
node.parentNode.insertBefore(newLinkElement,middleText);
v=node.parentNode.style.display;
//Check if we have a block element, and if not, flash it to
//avoid the redraw bug.
if (v!='block'){
node.parentNode.style.display='none';
node.parentNode.style.display=v;
}
skip=1;
}
}
}
return skip;
}
function hd_zzzzzz_Linkify(e){
document.removeEventListener('DOMContentLoaded', hd_zzzzzz_Linkify, false);
var elms = document.evaluate('//body//text()[not(ancestor::a)][not(ancestor::script)][not(ancestor::style)]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, elm; elm = elms.snapshotItem(i); i++) {
hd_zzzzzz_LinkifyNode(elm,document);
}
}
if (!window.location.href.match(/\.(txt|js|css|nfo)$/i) ){
document.addEventListener('DOMContentLoaded',hd_zzzzzz_Linkify,false);
}[ Szerkesztve ]
Új hozzászólás Aktív témák
Kérdés előtt olvasd el az
összefoglalót!
- Eredeti Microsoft termékek - MEGA Akciók! Windows, Office Pro Plus, Project Pro, Visio Pro stb.
- Steames kulcsok jó áron eladóak!
- Eredeti Windows, telepítéssel! Digital Doctor Számítógép Szerviz
- Új, bontatlan World of Warcraft gyűjtői kiadások
- Warhammer Online - Age of Reckoning (DE) Collectors Box (Figurával!)
Állásajánlatok
Cég: Alpha Laptopszerviz Kft.
Város: Pécs
Cég: Ozeki Kft.
Város: Debrecen