Posts that norz is monitoring

Subscribe to Posts that norz is monitoring 19 posts found

Jul 19, 2008
itsjareds 47 posts

Topic: Highlight specific words on any page...

How could I use this script to replace text smilies with images (data: uris)?

I cant figure it out

This is what I need to incorporate it in:


var happy = "data:image/gif;base64,R0lGODlhEQARALMAABy+ASTTAiXWAiHLAhWtARawAR7EARq ... ";

function replaceSmilie(smilie, surl)
{
  var reptext = new RegExp(smilie, "gi");
  document.body.innerHTML = document.body.innerHTML.replace(reptext, "<img src='" + surl + "' height='17' width='17' align='center' style='border:none;' />");
}

replaceSmilie(":\\)", happy);

Someone told me that using innerHTML replace was much slower, but I dont know how to use your way.

 
Jul 16, 2008
^tyrant^ 6 posts

Topic: Highlight specific words on any page...

is there another way to do the var? i added the words i want to highlight and its a pretty large list and it causes the script to stall

 
Jul 7, 2008
Mikado 575 posts

Topic: Highlight specific words on any page...

var RE = /(e)/;

for (var tx = document.evaluate('//text()[normalize-space(.)!=""]', document, null, 6, null), t, i = 0; t = tx.snapshotItem(i); i++) {
	var before =  t.textContent, st, matched = false;
	if (t.parentNode.tagName == 'STYLE' || t.parentNode.tagName == 'SCRIPT') continue;
	while ((st = before.search(RE)) != -1) {
		t.parentNode.insertBefore(document.createTextNode(before.substr(0, st)), t);
		with (t.parentNode.insertBefore(document.createElement('span'), t))
			textContent = RegExp.$1,
			style.cssText = 'color: #f00; font-size: 14pt;';
		matched = true;
		before = before.substr(st + RegExp.$1.length);
	}
	if (matched) t.textContent = before;
}

 
Jul 6, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

not working for me.
can't you just repost the full (working) script?

 
Jul 6, 2008
Mikado 575 posts

Topic: Highlight specific words on any page...

Working for me.

 
Jul 5, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

nope, still not working.

 
Jul 5, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

k.

 
Jul 5, 2008
Mikado 575 posts

Topic: Highlight specific words on any page...

I've mismatched quotes in that line, try again.

 
Jul 4, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

please.

 
Jul 4, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

multi word/case insensivity worked.
without replacing the color code.

but when I replace, the script doesnt work at all.

 
Jul 4, 2008
Mikado 575 posts

Topic: Highlight specific words on any page...

husamn wrote:

but is there a way I can add more words? <...> also when I add a word like (My Home) it only highlights exactly as it's typed, like it doesn't highlight (my home) just (My Home)

var RE = /(phrase one|phrase two|etc)/i; - i at the end stands for case insensivity.

husamn wrote:

and also color them instead just bold?

Replace t.parentNode.insertBefore(document.createElement('b'), t).textContent = RegExp.$1; with:

with (t.parentNode.insertBefore(document.createElement('span'), t))
	textContent = RegExp.$1,
	style.cssText = 'color: #f00; size: 14pt;';

Add any styles you like to the cssText string.

 
Jul 4, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

please.

 
Jul 4, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

thanks mikado, worked...but is there a way I can add more words? and also color them instead just bold?

also when I add a word like (My Home) it only highlights exactly as it's typed, like it doesn't highlight (my home) just (My Home)
with capital letters.

thanks.

 
Jul 3, 2008
dob 265 posts

Topic: Highlight specific words on any page...

That's why I'm still learning :)

 
Jul 3, 2008
Mikado 575 posts

Topic: Highlight specific words on any page...

Crappy way, dob.

var RE = /(script)/;

for (var tx = document.evaluate('//text()[normalize-space(.)!=""]', document, null, 6, null), t, i = 0; t = tx.snapshotItem(i); i++) {
	var before =  t.textContent, st, matched = false;
	if (t.parentNode.tagName == 'STYLE' || t.parentNode.tagName == 'SCRIPT') continue;
	while ((st = before.search(RE)) != -1) {
		t.parentNode.insertBefore(document.createTextNode(before.substr(0, st)), t);
		t.parentNode.insertBefore(document.createElement('b'), t).textContent = RegExp.$1;
		matched = true;
		before = before.substr(st + RegExp.$1.length);
	}
	if (matched) t.textContent = before;
}

 
Jul 3, 2008
dob 265 posts

Topic: Highlight specific words on any page...

var b = document.body;
b.innerHTML = b.innerHTML.replace(new RegExp("("+"your word"+")"), "<span style='color:#f00;font-weight:bold;'>$1</span>");

 
Jul 3, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

please.

 
Jul 3, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

please.

 
Jul 2, 2008
husamn 27 posts

Topic: Highlight specific words on any page...

is there a script that highlights specific words that I want on any site/page?