User Script
Posted by: DachaArh
Date: April 08, 2008 10:39AM

I can't find anywhere user script that does AUTO COPY of text that works with k-meleon.

Can someone do that?

thanks in advance

Re: User Script
Posted by: jk--
Date: April 09, 2008 01:36AM

post a link to the one that works for firefox

Re: User Script
Posted by: DachaArh
Date: April 09, 2008 06:13AM

for firefox I do not havw script that does auto copy, I have addon:
https://addons.mozilla.org/en-US/firefox/addon/383

for Opera I have user script, auto copy it goes like this :
// ==UserScript==
// @name Autocopy
// @author Lex1
// @version 1.1.1
// ==/UserScript==

document.addEventListener("mouseup", function(e){if(document.getSelection()){
var html_selection=document.createElement('div');
html_selection.appendChild(window.getSelection().getRangeAt(0).cloneContents());
var lnks = html_selection.getElementsByTagName('*'); for(var i=0, li; li=lnks; i++){if(li.href)li.href=li.href;if(li.src)li.src=li.src};

var fr=document.createElement('iframe'); fr.setAttribute('id', 'tr_dummy');fr.setAttribute('frameborder', '0');
fr.setAttribute('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;');
fr.setAttribute('src', 'data:text/cwf;charset=UTF-8,'+encodeURIComponent('SourceURL:'+document.location+'\r\n\r\n<html><head><meta http-equiv=Content-Type content=\'text/html; charset=utf-8\'></head><body><!--StartFragment-->'+html_selection.innerHTML+'<!--EndFragment--></body></html>'));
document.documentElement.appendChild(fr); var tr=document.getElementById('tr_dummy');if(tr){tr.parentNode.removeChild(tr)};
}},false);



Edited 1 time(s). Last edit at 04/09/2008 06:13AM by DachaArh.


Re: User Script
Posted by: jk--
Date: April 09, 2008 10:37AM

Error: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsISelection.getRangeAt]
Source file:

I'm getting this with km sad smiley

Re: User Script
Posted by: DachaArh
Date: April 09, 2008 10:57AM

can we make it work ? sad smiley

Re: User Script
Posted by: Lex1
Date: April 28, 2008 12:54PM

You can use similar code (flash-player need)
// ==UserScript==
// @name Autocopy
// @author Lex1
// @version 0.1
// @include *
// ==/UserScript==


(function(){
document.addEventListener('mouseup', function(e){ if(window.getSelection && window.getSelection() != '')toClipboard(window.getSelection()); }, false);

var copyDv;
var toClipboard = function(x){
	  if(!copyDv){
		    copyDv = document.createElement("div");
		    copyDv.style.visibility="hidden";
		    document.body.appendChild(copyDv);
		  }
		  copyDv.innerHTML= '<embed src="http://www.febooti.com/scripts/clipboard.swf"; FlashVars="clipboard='+x+'" width=0 height=0 type="application/x-shockwave-flash"></embed>';
	}
})();


Re: User Script
Posted by: Lex1
Date: April 28, 2008 01:37PM

Small fix.
// ==UserScript==
// @name Autocopy
// @author Ayush & Lex1
// @version 0.2
// @include *
// ==/UserScript==


(function(){
document.addEventListener('mouseup', function(e){ if(e.which == 1 && window.getSelection() != '')toClipboard(window.getSelection()); }, false);

function toClipboard(x){
	  var copyDiv = document.getElementById('ujs_copyDiv');
	  if(!copyDiv){
		    copyDiv = document.createElement('div');
		    copyDiv.id = 'ujs_copyDiv';
			copyDiv.style.visibility='hidden';
		    document.body.appendChild(copyDiv);
		  }
		  copyDiv.innerHTML= '<embed src="http://www.febooti.com/scripts/
clipboard.swf" FlashVars="clipboard='+encodeURIComponent(x)+'" width=0 height=0 type="application/x-shockwave-flash"></embed>';
	}
})();


K-Meleon forum is powered by Phorum.