You need to be logged in to post in the forums. If you do not have an account, please sign up first.
text-replacement-utf-8.js
And again, few month after publishing on russian operafan.net forum I eventually decided to publish here few of my scripts. Some decent ones I'm not ashamed of.text-replacement-utf-8.js (discussion on operafan).
Script is encoded in UTF-8, and that is necessary for correct interpetation of non-ASCII and Unicode symbols. First 'unneeded' semicolon is necessary too. Don't change it.
You can add your own replacements like (to replace 'foo' to 'bar'):
'foo','bar',
You can make some formatting in replaced text:
'foo','<b>bar</b>',
But it is recommended to make formatting with CSS in 'replacedText' tag:
'foo','<replacedText style="font-weight:bold">bar</replacedText>',
There are more advanced examples in script.
And make sure that replacement doesn't contain replaced text or you will face recursive and infinite cycle.
It uses DOM iterators to traverse text nodes, so speed is better that it might be, but still is an issue if you have are viewing big pages (>1Mb).
Convert2PHF.js -- saving in single htm or mht file
http://my.opera.com/profiT/homes/files/logotyps.htm
Convert2PHF.js -- saving in single htm or mht file
so if in the page source has e.g.
<b><u>J</u></b>is it changeable?
You can do something like:
document.documentElement.innerHTML=document.documentElement.innerHTML.replace(/<b><u>J<\/u><\/b>/ig,"<b><u>replaced!</u></b>");
But speed... Especially in case when you have many replacements...
Convert2PHF.js -- saving in single htm or mht file
, what to include to make the script site specific? let's say i want the script only to replace text in certain site(s)
I've squashed few bugs and tried to improve functionality:
Fixes, to make it work on any page.
Script won't do replacements on a big pages to prevent lags.
Ignoring contents of PRE tags.
Thanks everyone for feedback.
Now, next part is for js-geeks.
To filter some branches from the DOM-tree (to properly ignore all contents of PRE, STYLE, SCRIPT nodes), first i've converted script to TreeWalker but speed degraded by visible extent, so i decided to keep on with NodeIterator, but i had to use data directly attached to DOM nodes, to hash hiearchy information and it's kinda obtrusive...
Those interested may have a look to a TreeWalker version.
Convert2PHF.js -- saving in single htm or mht file
Originally posted by profiT:
How about a xpath snapshot ?Now, next part is for js-geeks.
//text()[not(parent::script) and not(parent::style) and not(ancestor::pre)]
http://my.opera.com/xErath/blog/
Originally posted by xErath:
How about a xpath snapshot ?
I am writting this script mostly for myself, and i still use 8.52 for my everyday browsing.
But i may add this, even if i won't use it for now...
Convert2PHF.js -- saving in single htm or mht file
Not for me

I save it on my Profile\UserJS folder and restarted Opera, but it seems not working :´(

CustomButtons.html; MyEmoticons - botão + menu com todos os smilies do MSN (independente da skin)
Dicas sobre o cliente de IRC do Opera!!
My O9.6 Userbars: em português - in english
have you set the userjs folder in tools -> preferences -> advanced -> content -> javascript options -> user javascript folder

I created a UserJS folder into my own profile folder (C:\Documents and Settings\<MyUserName>\Application Data\Opera\Opera\profile\UserJS\)
Then I copied the text-replacement-utf-8.js file into that folder.
I also setted this path as the user javascript folder.
It's the one file into that folder.
I restarted Opera.
Then I go to the sample page at http://my.opera.com/profiT/homes/files/logotyps.htm but nothing happens! I don't see the text translated into logos

I looked the logs of my VirusScan and appears it is NOT blocking me :O
I didn't read the UserJS tutorial, but I guessed it was as easy as the steps I did. I'm wrong?
Opera 9.1 final, WinXP SP2
Any ideas?

CustomButtons.html; MyEmoticons - botão + menu com todos os smilies do MSN (independente da skin)
Dicas sobre o cliente de IRC do Opera!!
My O9.6 Userbars: em português - in english
Is Javascript in your F12 menu checked?..
Have you tried relocating your userJS folder (to make it "c:\userJS", for example)?
And your error console (Tools -- Advanced -- Error console)? Does it say anything?
Or maybe site-preferences for my.opera.com?
By the way, i've just updated script a bit. Nothing really useful, just added few embedded images in two logos ('Google', 'Firefox') and support for them to script.
Convert2PHF.js -- saving in single htm or mht file
But then I copied the script into my profile again, and setted this folder as the userJS folder (again). After the weekend, I turned ON my PC and it works too!!!
As stated in my post in the thread "[Req] my.opera.com emoticons everywhere":
I'm using the Opera's IRC client + BitlBee ( http://bitlbee.org - an IRC to other chat networks gateway) for my chat needs.
But then I can't see the smilies I send/receive (besides the few supported by M2)!
So I'm making a custom menu with all the smilies used in MSN messenger and the MyOpera forums. I already got the images, put them into a test skin, and created the menu. I click on the smiley and the menu inserts the proper text.
But then I need a way to also interpret a received text and translate it into a smiley! This is why I want this UserJS working
But seems this JS don´t works on M2 or the IRC client
I did send a mail to myself with the string "^_^" and it wasn´t translated into a smile.See the replys of philry4n to my post.
Can you help? Thank you!


CustomButtons.html; MyEmoticons - botão + menu com todos os smilies do MSN (independente da skin)
Dicas sobre o cliente de IRC do Opera!!
My O9.6 Userbars: em português - in english
smiley is hardcoded, so it's not possible atm, i also heard that this has been asked before

How about using the IM.CSS file for this?

CustomButtons.html; MyEmoticons - botão + menu com todos os smilies do MSN (independente da skin)
Dicas sobre o cliente de IRC do Opera!!
My O9.6 Userbars: em português - in english
22. February 2007, 15:53:53 (edited)
I changed a skin, creating a MSN folder into the smilies folder and putting into it all the MSN emoticons.
In the skin.ini file I have a line like this:
Emoticon MSN_embarrassed = smilies/MSN/embarrassed.png
Then I zipped again the skin and make it the current skin.
Then I changed the script to translate '^_^' to the MSN's embarrassed emoticon
'^_^', '<replacedText style=\'display:inline-block; width: -o-skin; height: -o-skin; background-image: -o-skin("Emoticon MSN_embarrassed")\'></replacedText>',
Then I opened a test .htm page with the '^_^' string and it was translated to the correct emoticon!!
But when I see a mail I send to myself with the same string, it wasn't translated.
So IT IS possible to use addittional emoticons, but not into M2 (and I guess into the IRC client too)


CustomButtons.html; MyEmoticons - botão + menu com todos os smilies do MSN (independente da skin)
Dicas sobre o cliente de IRC do Opera!!
My O9.6 Userbars: em português - in english
Convert2PHF.js -- saving in single htm or mht file
New features:
- Now replacements have pop-up hints with original text.
- Clicking on replacement will disable them (all of them on the page), click again -- and they will show up again.
Convert2PHF.js -- saving in single htm or mht file