Sunday, October 14, 2012 12:21:35 AM
How to highlight selected text in yellow before saving
an html file by using a mouse gesture, a keyboard shortcut or a context
menu item.
Select text and use this code:
Ctrl G=Enable javascript & Delay, 10 & Go to page,"javascript:(function(){var sel=document.createElement('div'); var yel_sel=document.createElement('div');sel.appendChild(window.getSelection().getRangeAt(0).cloneContents());var html=document.documentElement;yel_sel.innerHTML='<span style=background-color:yellow>'+ sel.innerHTML +'</span>';html.innerHTML=html.innerHTML.replace(sel.innerHTML,yel_sel.innerHTML);window.prompt('',html.innerHTML)})()" & Delay, 100 & Copy & Click default button & Delay, 100 & View document source & Delay, 30 & Select all & Paste & Delay, 10 & Go to start
or
GestureRight, GestureDown, GestureUp=
or
Item, "Highlight selection"=
Enable javascript & Delay, 10 & Go to page,"javascript:(function(){var sel=document.createElement('div'); var yel_sel=document.createElement('div');sel.appendChild(window.getSelection().getRangeAt(0).cloneContents());var html=document.documentElement;yel_sel.innerHTML='<span style=background-color:yellow>'+ sel.innerHTML +'</span>';html.innerHTML=html.innerHTML.replace(sel.innerHTML,yel_sel.innerHTML);window.prompt('',html.innerHTML)})()" & Delay, 100 & Copy & Click default button & Delay, 100 & View document source & Delay, 30 & Select all & Paste & Delay, 10 & Go to start
NOTE: Opera blog breaks the code:
One has to manually copy the code and remove two spaces in "< span style=background" and "< /span>"
NOTE:
It's not fully automatic, because the Opera source viewer doesn't have the command "Apply Changes". So when the script opens the source viewer, one has to manually click "Apply Changes" and close the source viewer. Then the original webpage will have been changed and ready to be saved.
No comments:
Post a Comment