Copying text with formatting to clipboard and Autocopy.js
Friday, 14. August 2009, 09:14:40
I forgot to mention about it before 
Program for copying text with links and images to clipboard, from menu of Opera. Also included autocopy.js: htm2clip.zip (Installer).
Thread.
In Opera 10 you can use button Edit mode and simple copy/paste.
Or just button: Copy with formatting (drag'n'drop this button directly on panel).
Program for copying text with links and images to clipboard, from menu of Opera. Also included autocopy.js: htm2clip.zip (Installer).
Thread.
In Opera 10 you can use button Edit mode and simple copy/paste.
Or just button: Copy with formatting (drag'n'drop this button directly on panel).


Anonymous # 28. February 2008, 03:01
Where do I install this js file in Opera?
Lex1 # 28. February 2008, 10:54
Jozkavs # 13. August 2008, 14:15
when pasting the content into a web page, it pasts again only a text and when pasting it into MS Word, it surprisingly pasts a word "undefined"...?
Lex1 # 15. August 2008, 10:24
Script autocopy.js is work. Item menu don't work, because it's page with frames.
Fixed.
Lex1 # 6. September 2008, 14:48
oke # 22. December 2008, 18:00
This JS to "copy text with formatting" worked great until Opera version 9.62 but it stopped working after upgrading to 9.63
I am using Win XP Service Pack 3. All my JS settings as well as the configs for htm2clip still seems fine, and I have not done any other changes to my setup.
Do other people also have this problem or did something go wrong with my upgrade?
Lex1 # 22. December 2008, 18:32
oke # 23. December 2008, 14:05
Thanks for the workaround information on 9.63 It works fine.
scoobedoo # 30. December 2008, 04:03
I've installed your fix for html2clip on 9.63 and even after following the link above, I am unable to copy anything to the clipboard. I'm sure that the 'Copy text with formatting' link is calling html2clip.exe because if I rename the exe Opera complains about it. I have also made sure that all references to cache4 in about:config use DOS paths with ~1. So, I guess I'm stumped and ANY help would be appreciated! (I'm trying to get away from Firefox - I realized I was spending all my time trying to add features to it that Opera already had by default!)
This feature is the last thing I need for productivity (for MS OneNote usage) so any help would be great.
Is there anything else I can check or try?
Carlo
Lex1 # 31. December 2008, 00:01
Do you use content blocker?
scoobedoo # 6. January 2009, 03:21
Thanks for replying. Yes I do, but I have tried this on pages (like this one or google.com) where I haven't blocked any content. I also just tried disabling content blocking via the Site Preferences dialog and then trying it again. I see the same as before: I highlight a section, right click, press 'Copy text with formatting', the status bar pops up suggesting something is being loaded (status bar is hidden normally), and then I switch programs and nothing has been copied.
If it helps, I'm on Windows XP SP3 and Opera 9.63.
Other thoughts?
Carlo
Lex1 # 6. January 2009, 09:00
Rename Opera\program\htm2clip.exe. Copy ShowCmdLine.exe as Opera\program\htm2clip.exe.
Highlight a section, right click, press 'Copy text with formatting' and post here result.
Open (with notepad) a file from the command line and post content here.
scoobedoo # 6. January 2009, 18:26
Default(48) file output as copied from notepad. I tried copying part of my message to you above with the 'Edit' and Delete' links highlighted.
------------------------------------------------
SourceURL:http://my.opera.com/Lex1/blog/copying-text-with-formatting-to-clipboard-and-autocopy-js?cid=6732666
<HTML lang="en"><HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="EditURI" type="application/rsd+xml" title="RSD" href="/Lex1/xml/rsd">
<META name="viewport" content="width=device-width">
<LINK rel="stylesheet" href="/community/css/main.css" type="text/css" media="screen,projection,tv,print">
<STYLE type="text/css" media="screen,projection,tv,print">
#intro p.imgtext { display:none; }
</STYLE>
<LINK rel="stylesheet" href="/community/css/mobile.css" type="text/css" media="handheld">
<LINK rel="stylesheet" href="/community/css/themes/common-1.css" type="text/css" media="screen,projection,tv,print">
<LINK rel="stylesheet" href="/community/css/themes/default.css" type="text/css" media="screen,projection,tv,print">
<LINK rel="stylesheet" href="/community/css/themes/mobile02.css" type="text/css" media="handheld">
<LINK rel="shortcut icon" href="/community/favicon.ico" type="image/x-icon">
<LINK rel="meta" type="application/rdf+xml" title="FOAF" href="/Lex1/xml/foaf/">
<LINK rel="alternate" type="application/rss+xml" title="RSS 2.0 Feed" href="/Lex1/xml/rss/blog/">
<LINK rel="alternate" type="application/atom+xml" title="Atom 1.0 Feed" href="/Lex1/xml/atom/blog/">
<LINK rel="alternate" type="application/rss+xml" title="RSS 2.0 Feed for comments" href="/Lex1/xml/rss/comments/1019855">
<LINK rel="alternate" type="application/atom+xml" title="Atom 1.0 Feed for comments" href="/Lex1/xml/atom/comments/1019855">
<LINK rel="alternate" type="application/x-opera-widgets" href="http://widgets.opera.com/widgetize/Feed%20Reader/Advanced/?serve&skin=skin1&widgetname=My%20program%20for%20Opera&rel=myopera&ref=Lex1">
</HEAD><BODY id="myopera">
If it helps, I'm on Windows XP SP3 and Opera 9.63.
Other thoughts?
Carlo
[ EDIT | DELETE ]
scoobedoo # 6. January 2009, 18:34
Lex1 # 6. January 2009, 20:21
scoobedoo # 7. January 2009, 16:20
Mine is set to:
C:\Docume~1\scoob_e_doo\Locals~1\Applic~1\Opera\Opera\profile\cache4\temporary_download\
Which resolves perfectly fine in Explorer.
Can I ask what htm2clip.exe invokes to copy the 'default(xx)' files to the clipboard? I feel like that is my problem.
Lex1 # 23. January 2009, 20:53
Program ShowCmdLine.exe (renamed to the htm2clip.exe) shows this path?
Yes.
Anonymous # 2. February 2009, 10:59
Hi. I CANNOT get this to work in LINUX. Running the .exe using WINE does nothing. I copy the .js files to a Userjs directory and then in Opera settings point to that directory for the Javascript BUT I get no menu items?!
Please help
zcat
mesmol # 8. February 2009, 22:26
unfortunately htm2clip don't work in 9.63
when i click on Copying text with formatting in contextmenu only phrase of "Copying text with formatting" copy to clipboard!!!!
plz help me
Lex1 # 9. February 2009, 11:22
Tommy27 # 12. February 2009, 08:46
did u find a way to fix this issue?
Tommy27 # 12. February 2009, 08:54
Lex1 # 12. February 2009, 19:09
Tommy27 # 13. February 2009, 13:46
my question is: does html2clip work on Oepra 9.63 or is the new Opera release not comaptible with it?
whta should i do to make it work?
Lex1 # 13. February 2009, 14:24
Yes. After changing the path to temporary_download.
Tommy27 # 13. February 2009, 15:11
which path are you talking about?
do you have step by step instructions?
Lex1 # 13. February 2009, 15:18
Tommy27 # 14. February 2009, 14:21
thank you very much for the nice html2clip program and the suggestions to make it work on Opera 9.63
Tommy27 # 15. February 2009, 11:02
Lex1 # 15. February 2009, 11:58
Tommy27 # 15. February 2009, 13:23
i was able to move it on top and to keep a copy of it at the bottom too.
i had only to slightly rename the menu item name since u can't have 2 menu items with the same name.
here's the code:
[Hotclick Popup Menu]
Platform Windows, Item, "Copy text with formatting"="Go to Page, "javascript:(function(){var encodeBase64=function(a){var b='';var c=0;var i=0;var d='';var e=a.length;var f=[];var g='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';while(c=a.charCodeAt(i++)){if(c<0x80){f[f.length]=c}else if(c<0x800){f[f.length]=0xc0|(c>>6);f[f.length]=0x80|(c&0x3f)}else if(c<0x10000){f[f.length]=0xe0|(c>>12);f[f.length]=0x80|((c>>6)&0x3f);f[f.length]=0x80|(c&0x3f)}else{f[f.length]=0xf0|(c>>18);f[f.length]=0x80|((c>>12)&0x3f);f[f.length]=0x80|((c>>6)&0x3f);f[f.length]=0x80|(c&0x3f)}if(i==e){while(f.length%%3){f[f.length]=0;d+='='}}if(f.length>2){b+=g[f[0]>>2];b+=g[((f.shift()&3)<<4)|(f[0]>>4)];b+=g[((f.shift()&0xf)<<2)|(f[0]>>6)];b+=g[f.shift()&0x3f]}}return(b+d)};var selWin=function(w){if(w.getSelection()!='')return w;for(var i=0,f,r;f=w.frames;i++){try{if(r=arguments.callee(f))return r}catch(e){}}};var win=selWin(window);if(win){var doc=win.document;var link=win.location.href;if(win.location.protocol=='file:')link=link.replace('localhost','');var sel=doc.createDocumentFragment();var range=win.getSelection().getRangeAt(0);sel.appendChild(doc.createComment('StartFragment'));sel.appendChild(range.cloneContents());sel.appendChild(doc.createComment('EndFragment'));var ele=range.commonAncestorContainer;while(ele){if(ele.nodeType==1){var clone=ele.cloneNode(false);clone.appendChild(sel);sel=clone};ele=ele.parentNode};var head=doc.getElementsByTagName('head')[0];if(head){var h=sel.insertBefore(head.cloneNode(true),sel.firstChild);var b=h.getElementsByTagName('base')[0];if(!b){b=doc.createElement('base');h.insertBefore(b,h.firstChild)}if(!b.href)b.href=link;var m=h.getElementsByTagName('meta');for(var i=0,mi;mi=m;i++){if(mi.httpEquiv&&mi.httpEquiv.toLowerCase()=='content-type')mi.content='text/html; charset=utf-8'}};var scripts=sel.getElementsByTagName('script');for(var i=scripts.length-1;i>=0;i--){scripts.parentNode.removeChild(scripts)};var doctype='';var dt=doc.doctype;if(dt&&dt.name){doctype+='<!DOCTYPE '+dt.name;if(dt.publicId)doctype+=' PUBLIC \x22'+dt.publicId+'\x22';if(dt.systemId)doctype+=' \x22'+dt.systemId+'\x22';doctype+='>\n'};var f=doc.createElement('iframe');f.width=0;f.height=0;f.frameBorder='no';f.scrolling='no';f.src='data:text/cwf;charset=UTF-8;base64,'+encodeBase64('SourceURL:'+link+'\r\n\r\n'+doctype+sel.outerHTML);doc.documentElement.appendChild(f);f.parentNode.removeChild(f)}})();",,,"Copy""
--------------------1
Item, MI_IDM_DOCCOPY= Copy
Item, M_COPY_TO_NOTE= Copy to note
Platform Win2000-Unix-Mac-QNX, Feature Voice, Item, M_HOTCLICK_MENU_ITEM_SPEAK = Speak selection
--------------------2
Item, MI_IDM_SELSEARCH= Hotclick search, 200
Submenu, MI_IDM_SEARCH_DUMMY_PARENT, Internal Search With
Item, MI_IDM_SELDICTIONARY= Hotclick search, 50
Item, MI_IDM_SELENCYCLOPED= Hotclick search, 51
--------------------3
Submenu, MI_IDM_SELTRANSLATE_EN_FR_PARENT, Translate menu
Item, M_HOTCLICK_POPUP_MENU_GOTO_URL= Go to page, "%t"
Item, MI_IDM_SELMAIL= Send text in mail
--------------------4
Platform Windows, Item, "Copy text with formatting "="Go to Page, "javascript:(function(){var encodeBase64=function(a){var b='';var c=0;var i=0;var d='';var e=a.length;var f=[];var g='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';while(c=a.charCodeAt(i++)){if(c<0x80){f[f.length]=c}else if(c<0x800){f[f.length]=0xc0|(c>>6);f[f.length]=0x80|(c&0x3f)}else if(c<0x10000){f[f.length]=0xe0|(c>>12);f[f.length]=0x80|((c>>6)&0x3f);f[f.length]=0x80|(c&0x3f)}else{f[f.length]=0xf0|(c>>18);f[f.length]=0x80|((c>>12)&0x3f);f[f.length]=0x80|((c>>6)&0x3f);f[f.length]=0x80|(c&0x3f)}if(i==e){while(f.length%%3){f[f.length]=0;d+='='}}if(f.length>2){b+=g[f[0]>>2];b+=g[((f.shift()&3)<<4)|(f[0]>>4)];b+=g[((f.shift()&0xf)<<2)|(f[0]>>6)];b+=g[f.shift()&0x3f]}}return(b+d)};var selWin=function(w){if(w.getSelection()!='')return w;for(var i=0,f,r;f=w.frames;i++){try{if(r=arguments.callee(f))return r}catch(e){}}};var win=selWin(window);if(win){var doc=win.document;var link=win.location.href;if(win.location.protocol=='file:')link=link.replace('localhost','');var sel=doc.createDocumentFragment();var range=win.getSelection().getRangeAt(0);sel.appendChild(doc.createComment('StartFragment'));sel.appendChild(range.cloneContents());sel.appendChild(doc.createComment('EndFragment'));var ele=range.commonAncestorContainer;while(ele){if(ele.nodeType==1){var clone=ele.cloneNode(false);clone.appendChild(sel);sel=clone};ele=ele.parentNode};var head=doc.getElementsByTagName('head')[0];if(head){var h=sel.insertBefore(head.cloneNode(true),sel.firstChild);var b=h.getElementsByTagName('base')[0];if(!b){b=doc.createElement('base');h.insertBefore(b,h.firstChild)}if(!b.href)b.href=link;var m=h.getElementsByTagName('meta');for(var i=0,mi;mi=m;i++){if(mi.httpEquiv&&mi.httpEquiv.toLowerCase()=='content-type')mi.content='text/html; charset=utf-8'}};var scripts=sel.getElementsByTagName('script');for(var i=scripts.length-1;i>=0;i--){scripts.parentNode.removeChild(scripts)};var doctype='';var dt=doc.doctype;if(dt&&dt.name){doctype+='<!DOCTYPE '+dt.name;if(dt.publicId)doctype+=' PUBLIC \x22'+dt.publicId+'\x22';if(dt.systemId)doctype+=' \x22'+dt.systemId+'\x22';doctype+='>\n'};var f=doc.createElement('iframe');f.width=0;f.height=0;f.frameBorder='no';f.scrolling='no';f.src='data:text/cwf;charset=UTF-8;base64,'+encodeBase64('SourceURL:'+link+'\r\n\r\n'+doctype+sel.outerHTML);doc.documentElement.appendChild(f);f.parentNode.removeChild(f)}})();",,,"Copy""
teknomobil # 16. May 2009, 12:22
Very good Opera 10 button
teknomobil # 12. June 2009, 17:03
Opera 10 beta not Rich Text Copy:cry:
Button does not work anymore
Please update fix button.
Thanks
ZAHEK # 1. July 2009, 08:20
Firstly ,thanks for this.It works in now Opera 10 v.1601 and copied contetnt should be paste to MS word , MS Office, Macromedia Dreamweaver, etc.as RTF with images.
Bu tas Teknomobil said above, it is not possible to copy in Opera Mail with images..Do you know its reason?
or it is possbile to do it?
Lex1 # 1. July 2009, 11:49
Maybe in future Opera Mail will be work with links...
Lex1 # 3. July 2009, 11:51
Better work with css. Now css-rules are copied , instead of links on *.css-files.
Tommy27 # 27. July 2009, 20:22
Lex1 # 29. July 2009, 09:41
Tommy27 # 11. August 2009, 14:34
do we still need this JS in Opera 10 or this feature will be present by defualt in the forthcoming Opera 10 final version?
P.S. i haven't tried yet Opera 10
Lex1 # 11. August 2009, 21:46
Tommy27 # 12. August 2009, 07:25
we are lucky you did that job
collents # 9. September 2009, 13:46
I read through the forum post and got utterly confused so I'm glad I just found this now. I just added the "Edit mode" button to my status bar (I use Opera Unite build 1691) and it works like a charm. I copied and pasted formatted text and images into Windows Live Writer, though it worked better pasting into Word - sometimes the formatting was lost in Live Writer (possible where it was formatted with CSS).
But it works well enough for me. Just one thing - when it copies links it copies relative links rather than absolute ones. Anything you can do about that? I understand why it does it, I just hope you know of a solution.
Lex1 # 9. September 2009, 17:56
htm2clip or something liked:
Go to page, "javascript:(function(){var links=document.getElementsByTagName('a');for(var i=0,link;link=links[i];i++){if(link.href)link.href=link.href};document.designMode=(document.designMode=='on')?'off':'on'})()",,"Edit mode","News Read"collents # 9. September 2009, 21:32
Originally posted by Lex1:
Sorry, I don't understand - do I need to run your installer and put this code somewhere, or can the button code be altered in any way?
Lex1 # 10. September 2009, 07:33
Anonymous # 27. September 2009, 06:37
Hi.
Just wanna say thanks, i was about to skip using Opera just because of the copy/paste thingy.
But now it works with that work around.
Tommy27 # 6. October 2009, 15:02