greetings to all forum users
I'd like to create a user script for Firefox that allow me to paste the content of the clipboard by a pressure of the central mouse button (I'm on Windows 8.1).
I'm a newbie and I found a script that maybe it can be a good starting point Endor8 /userChrome.js
// ==UserScript==
// @name overwriteMiddleMousePaste.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// ==/UserScript==
document.documentElement.addEventListener("click", function(event){
if (event.button !== 1 || !gPrefService.getBoolPref('middlemouse.paste')) return;
var localName = event.target.localName.toLowerCase();
// 元のコード
// if ((localName === 'input' || localName === 'textarea' || localName === 'textbox') &&
if ((localName === 'input' || localName === 'textarea' || localName === 'textbox' || localName === 'tabbrowser' || localName === 'searchbar') &&
document.commandDispatcher.getControllerForCommand("cmd_paste") ){
goDoCommand("cmd_paste");
event.preventDefault();
}
}, true);
I modded it, however this isn't still a working script
// ==UserScript==
// @name overwriteMiddleMousePaste.uc.js
// @namespace http://d.hatena.ne.jp/Griever/
// @include main
// ==/UserScript==
document.addEventListener("click", function(event){
if (event.button !== 1) return;
var localName = event.target.localName.toLowerCase();
var command='cmd_paste'
var controller=document.commandDispatcher.getControllerForCommand(command);
if ((localName === 'input' || localName === 'textarea' || localName === 'textbox' || localName === 'tabbrowser' || localName === 'searchbar' || localName === 'iframe' || localName === 'frame' || localName === 'input:nth-child(3)') && controller.isCommandEnabled(command)){
controller.doCommand(command);
event.stopPropagation();
event.preventDefault();
}
}, true);
It doesn't work on any html element (search boxes, etc.) nor on Firefox sidebar. It only works on Firefox urlbar and findbar