Полезная информация

Общайтесь со знакомыми и друзьями в нашем сообществе в Facebook.

№1372613-09-2019 13:35:39

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 68.0

Re: Custom Buttons

Dumby
Есть отчего впасть в отчаянье...Кнопки на мульти...Нет панацеи? Try код, что ли... Заманаешься рихтовать. Видео, перевод и еще кое-что...
Курвье будали , душманци...

Отсутствует

 

№1372713-09-2019 14:04:10

func4ptch4
Участник
 
Группа: Members
Зарегистрирован: 03-05-2018
Сообщений: 144
UA: Firefox 69.0

Re: Custom Buttons

solombala пишет:

перевод...

Combine-Translate - https://forum.mozilla-russia.org/viewto … 93#p771793
Google-Translate  - https://forum.mozilla-russia.org/viewto … 88#p771788

Отредактировано func4ptch4 (13-09-2019 14:06:06)

Отсутствует

 

№1372813-09-2019 15:19:50

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 68.0

Re: Custom Buttons

func4ptch4
Это хорошо. Еще гора кнопок в ауте...Кнопка видео в плеер, как без нее..

скрытый текст

Выделить код

Код:


/*Initialization Code*/

var path = 'C:\\PotPlayer\\PotPlayer.exe'

var sysPlayerName = "POTlayer";

var openIn = "Откыть в "+sysPlayerName;
var videoMoved = "Видео перенесено в "+sysPlayerName;
var noFound = "Не найдено видео на странице, доступное для переноса в "+sysPlayerName;

var YoutubeID = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\W|$)/;



if(!(cbu.getPrefs("CB.video")) || cbu.getPrefs("CB.video").length < 9) cbu.setPrefs("CB.video", "videotoplayer");
var tmp = '',
tmpp = '',
innerA = '<div style="display:block!important;color:#00ff00!important;width:250px!important;font:bold 16px serif!important;z-index:999!important;opacity:1!important;visibility: visible!important;',
innerB = 'left:5px!important;position:absolute!important;height:auto!important;box-sizing:border-box!important;padding:5px!important;margin:5px!important;',
stopPl = "javascript:(function(){v=document.getElementById('movie_player');if(v){v.stopVideo()}else{v=document.getElementsByTagName('video');if(v){v[0].src='';try{v[0].load()}catch(e){}};}})();",
ytIMGouter = function(ytID) {return '<div width="100%"><br /><a target="_blank" href="https://www.youtube.com/watch?v=' + ytID + '"><img src="https://i.ytimg.com/vi/' + ytID + '/hqdefault.jpg"></a><br />' + innerA + 'background-color:black!important;position:relative!important;bottom:20px!important;">&nbsp;&nbsp;' + videoMoved + '</div><br /></div><br />'},
handlWin = function(currentWin) {
tmp = '';
var elem = currentWin.document.getElementsByTagName('video'), currLoc = currentWin.location;
if(elem.length > 0) {
if(currLoc.hostname.indexOf('youtu') != -1 && (tmp = currLoc.toString().match(YoutubeID)) && tmp[1].length == 11) {
play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
videoMovedbox = currentWin.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>';
loadURI(stopPl);
currentWin.document.getElementById('eow-title').appendChild(videoMovedbox);
return true;
};
for(i = 0; i < elem.length; i++) {
if(((tmp = getSrc(elem[i].parentNode, currLoc)) && tmp.length > 2) || (i == 0 && currentWin.document.body.innerHTML.substring(0, 7) == '<video ' && (tmp = currLoc.toString()))) {
videoMovedbox = currentWin.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:20px!important;background-color:black!important;">' + videoMoved + '</div>';
play(tmp);                
if(currLoc.hostname == 'www.youtube.com') {
elem[i].parentNode.parentNode.appendChild(videoMovedbox);
} else {
elem[i].parentNode.appendChild(videoMovedbox);
};
elem[i].src = '';
try {
elem[i].load()
} catch(e) {};
return true;
}
}
};

currentWin._elems = currentWin.document.getElementsByTagName('iframe');
if(currentWin._elems.length > 0) {
for(currentWin._iCounter = 0; currentWin._iCounter < currentWin._elems.length; currentWin._iCounter++) {
if((currentWin._elems[currentWin._iCounter].src.indexOf('youtube.com') > -1) && (tmp = currentWin._elems[currentWin._iCounter].src.match(YoutubeID)) && (tmp[1].length == 11)) {
play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
currentWin._elems[currentWin._iCounter].outerHTML = ytIMGouter(tmp[1]);
return true;
};
if(currentWin._elems[currentWin._iCounter].clientWidth > 80 && currentWin._elems[currentWin._iCounter].clientHeight > 40 && handlWin(currentWin._elems[currentWin._iCounter].contentWindow))return true;
}
};

elem = currentWin.document.getElementsByTagName('object');
currLoc = currentWin.location;
if(elem.length == 0) {
elem = currentWin.document.getElementsByTagName('embed')
};
if(elem.length > 0) {
for(i = 0; i < elem.length; i++) {
if(elem[i].innerHTML.indexOf('youtu') != -1 && (tmp = elem[i].innerHTML.match(YoutubeID)) && tmp[1].length == 11) {
play(cbu.getPrefs("CB.video") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
elem[i].outerHTML = ytIMGouter(tmp[1]);
return true;
} else {
if(elem[i].clientWidth > 80 && elem[i].clientHeight > 40) {
if(((tmp = getSrc(elem[i].parentNode, currLoc)) || (tmp = getLink(elem[i], currLoc))) && tmp.length > 2) {
play(tmp);
elem[i].outerHTML = innerA + 'background-color:black!important;bottom:20px!important;">&nbsp;&nbsp;' + videoMoved + '</div>';
return true;
};
};
}
};
};
return false;
};

this.onclick = this.oncontextmenu = e => {
if (e.target != this) return;
if(e.button == 0) {
if(cbu.getPrefs("CB.video").substring(0,6) == "videom"){
elem = content.document.getElementsByTagName('object');
if(elem.length == 0) {
elem = content.document.getElementsByTagName('embed')
};

resizeObjs(elem);
resizeObjs(content.document.getElementsByTagName('iframe'));
resizeObjs(content.document.getElementsByTagName('video'));
} else {
if(!handlWin(content))custombuttons.alertSlide1(noFound);
}
};

if ( e.button == 2 && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey ) { // ПКМ
e.preventDefault();
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
file.initWithPath('C:\\PotPlayer\\PotPlayer.exe');
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
var link = gClipboard.read();
var args = [link,"/play"];
process.init( file );
process.run( false, args, args.length );
}
};
this.oncontextmenu = e => e.target != this ? menu.hasAttribute("context")
    : e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || (
        e.detail != 1 ? menu.hidePopup() : !!menu.openPopup(this, "after_start")
    );
custombuttons.alertSlide1 = function(sTitle) {
var as = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);
as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null);
setTimeout(() => as.closeAlert(), 999);
};
this.tooltipText="Л: Видео в плеер\nП: Видео из Clipboard";
function resizeObjs(objs) {
if(!objs) return;
LEVELS = 3;
dir = (cbu.getPrefs("CB.video") == "videomaximize") ? 1 : -1;
for(i = 0; i < objs.length; i++) {
var Width = new Array(LEVELS)
var Height = new Array(LEVELS)
Width[0] = objs[i].clientWidth;
Height[0] = objs[i].clientHeight;
if((Width[0] > (-20 * dir + 100)) && (Height[0] > (-20 * dir + 60))) {
obj = objs[i];
for(var k = 1;
((k < LEVELS) && (obj.parentNode)); k++) {
obj = obj.parentNode
Width[k] = obj.clientWidth;
Height[k] = obj.clientHeight;
};
Width[0] = Width[0] + dir * (Width[0] / 5 | 0);
Height[0] = Height[0] + dir * (Height[0] / 5 | 0);
objs[i].style.width = Width[0] + "px";
objs[i].width = Width[0];
objs[i].style.height = Height[0] + "px";
objs[i].height = Height[0];
obj = objs[i];
for(var k = 1;
((k < LEVELS) && !(objs[i].tagName == 'IFRAME') && (obj.parentNode) && (Width[k]) && (Height[k]) && (Width[k] > (-20 * dir + 100)) && (Height[k] > (-20 * dir + 60))); k++) {
obj = obj.parentNode
Width[k] = Width[k] + dir * (Width[k] / 5 | 0);
Height[k] = Height[k] + dir * (Height[k] / 5 | 0);
obj.style.width = Width[k] + "px";
obj.width = Width[k];
obj.style.height = Height[k] + "px";
obj.height = Height[k];
}
}
};
};

function restProtHost(lnkR, curLoc) {
if(lnkR.length==0)return '';
let tr = lnkR.replace(/^:\/\//, curLoc.protocol + "//");
if(!tr.match(/^https?:\/\//i)){
lnkR = tr.replace(/^\/+/, '');
if(lnkR.split('/')[0].split('?')[0].split('#')[0].toLowerCase().match(/^(?:[-a-z\d]+\.)+[a-z\d]{2,6}$/)){
tr = curLoc.protocol + '//' + lnkR;
}else{
tr = curLoc.protocol + '//' + curLoc.host + "/" + lnkR;
}
};
return tr;
};

function getSrc(vobj, currentLoc) {
var t = '',
tt = '';
if((((t = vobj.innerHTML.match(/<video.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i)) && (t) && (tt = t[1] || t[2] || t[3]) && tt.indexOf('blob:') == -1 ) || ((t = vobj.innerHTML.match(/<source.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*)).*?\stype=['"]?video\//i)) && (t) && (tt = t[1] || t[2] || t[3]))) && tt.length > 2 && tt.indexOf('blob:') == -1 ) {
if(tt.indexOf(".mp4/?") == -1) {
tt = tt.replace(/&amp;/g, "&")
};
t = restProtHost(tt, currentLoc);
return t;
};
return '';
};

function getLink(obj, curLocation) {


if(!obj || !obj.tagName) return '';
var flashvars = '',
//        src = '',
q = obj.tagName.toLowerCase();

var getParam = function(e, n) {
var v = '',
r = new RegExp('^(' + n + ')$', 'i'),
param = e.getElementsByTagName('param');
for(var igp = 0, p; p = param[igp]; igp++) {
if(p.hasAttribute('name') && p.getAttribute('name').match(r)) {
v = p.getAttribute('value');
break
};
};
return v;
};


if(q == 'object') {
//        src = obj.getAttribute('data') || obj.getAttribute('src') || getParam(obj, 'movie|data|src|code|filename|url') || (obj.getElementsByTagName('embed').length > 0 ? obj.getElementsByTagName('embed')[0].getAttribute('src') : '');
flashvars = getParam(obj, 'flashvars');
} else if(q == 'embed') {
//        src = obj.getAttribute('src');
flashvars = obj.getAttribute('flashvars');
} else return '';


if(!flashvars) return '';
//   src = restProtHost(src, curLocation);

var restPath = function(f, s) {
return(f.substring(0, 4) == 'http') ? f : s.replace(/[#?].*$/, '').replace(/[^\/]*$/, f)
};

function videoLinkExtract(fl) {
//alert(fl);
var linkArr = [],
outLinks = [],
jj = 0,
lba = '',
lbb = '',
decodeURL = function(s) {
try {
return decodeURIComponent(s)
} catch(e) {
return unescape(s)
}
};

for(var ij = 0; ij < 3; ij++) {
lba = lba + String.fromCharCode(parseInt((Math.random() * 15 + 1) + '', 10));
lbb = lbb + String.fromCharCode(parseInt((Math.random() * 15 + 16) + '', 10));
};

function pushWithMerit(lnk) {

var merit = -11;
if(lnk.match(/^https?:\/\//i)) merit = merit + 40;
if(outLinks.length == 0) merit = merit + 1;
if(lnk.match(/^\//)) merit = merit + 7;
if(lnk.match(/^\/\//)) merit = merit + 30;
if(lnk.match(/240p([^a-z]|$)/i)) merit = merit + 1;
if(lnk.match(/[^a-z]240([^a-z0-9]|$)/i)) merit = merit + 1;
if(lnk.match(/360p([^a-z]|$)/i)) merit = merit + 3;
if(lnk.match(/[^a-z]360([^a-z0-9]|$)/i)) merit = merit + 3;
if(lnk.match(/480p([^a-z]|$)/i)) merit = merit + 5;
if(lnk.match(/[^a-z]480([^a-z0-9]|$)/i)) merit = merit + 5;
if(lnk.match(/720p([^a-z]|$)/i)) merit = merit + 7;
if(lnk.match(/[^a-z]720([^a-z0-9]|$)/i)) merit = merit + 7;
if(lnk.match(/\.mp4([^a-z]|$)/i)) merit = merit + 8;
if(lnk.match(/_hd([^a-z]|$)/i)) merit = merit + 6;
if(lnk.match(/\.(jpg|xml)([^a-z]|$)/i)) merit = merit - 40;
if(merit > 0) outLinks.push(merit + lba + lnk);
Services.console.logStringMessage('merit:'+merit+' lnk->'+lnk);
};

linkArr.push(fl);
while(linkArr.length > jj && jj < 30) {

var testPaths = [];
testPaths = linkArr[jj].split(/(\.(?:flv|mp4|m3u8))/i);
if(testPaths[testPaths.length - 1] == '') testPaths.pop();

for(k = 1; k < testPaths.length; k = k + 2) {

if(testPaths[k - 1].indexOf(lba) > -1) {
pref = testPaths[k - 1];
} else {
var testAboutDom = testPaths[k - 1].toLowerCase().split(/(https?:\/\/)/); 
if(testAboutDom[testAboutDom.length - 1]=='') testAboutDom.pop();
var pTest = testAboutDom[testAboutDom.length - 1].split(/(\?[^\?]*?&)/);
if(pTest.length>2){
pTest.pop();
pTest.pop();
};
testAboutDom[testAboutDom.length - 1] = pTest.join('');
pref = testPaths[k - 1].substring(testAboutDom.join('').lastIndexOf("&") + 1);
};

t2 = pref.lastIndexOf(lbb);
if(t2 > -1) {
pref = pref.substring(t2 + 3);
} else {

t2 = pref.lastIndexOf('{"');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.lastIndexOf('["');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.lastIndexOf(',"');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.toLowerCase().lastIndexOf('"http://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf('"https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(',http://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(',https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(';http');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf('*https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(' or ');
if(t2 > -1) pref = pref.substring(t2 + 4);

pref = pref.substring(pref.split('/')[0].toLowerCase().split('%2f')[0].lastIndexOf('=') + 1);

}

if(pref.length > 0) {

if(pref.split('?')[0].toLowerCase().match(/%[2-3][0-9a-f]/)) {

t2 = pref.indexOf('"')
if(t2 > -1) pref = pref.substring(t2 + 1);
suff = testPaths[k + 1] ? testPaths[k + 1].split('&')[0].split('"')[0].split(';')[0].split(/,http/i)[0] : '';
if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) {
if(testPaths.length > k + 1) {
testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length)
};
t2 = pref.lastIndexOf(lba);
if(t2 > -1) pref = pref.substring(t2 + 3)
linkArr.push(decodeURL(pref + testPaths[k] + suff));

} else {
testPaths[k + 1] = (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff
}
} else {
suff = testPaths[k + 1] ? testPaths[k + 1].split(';')[0].split('"]')[0].split('"}')[0].split('",')[0].split(/,https?:\/\//i)[0].split('*https://')[0].split(' or ')[0] : '';
t2 = suff.indexOf('&');
if((t2 > -1) && (pref != testPaths[k - 1])) {
if(t2 == 0) suff = '';
if(suff.charAt(0) != '?') suff = suff.split(/(&[^&]+=https?:\/\/)/i)[0];
};
if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) {
if(testPaths.length > k + 1) {
testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length)
};
t2 = pref.lastIndexOf(lba);
if(t2 > -1) pref = pref.substring(t2 + 3);
pushWithMerit(pref + testPaths[k] + suff);

} else {
testPaths[k + 1] = lba + (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff
}
}
}
};
jj = jj + 1;
};

if(outLinks.length == 0) return '';
function srt(a, b) {
a = parseInt(a.substr(0, a.indexOf(lba)), 10);
b = parseInt(b.substr(0, b.indexOf(lba)), 10);
if(a < b) return 1;
if(a > b) return -1;
return 0
};
outLinks.sort(srt);
outLinks[0] = outLinks[0].substr(outLinks[0].indexOf(lba) + 3)
if(outLinks[0].indexOf('_hq.mp4/?time=') > 0) outLinks[0] = outLinks[0].replace(/&/g, '&amp;');
return outLinks[0];
};
ol = videoLinkExtract(flashvars);
if(!ol) return '';
//    ol = ol.replace(/^:?\/\//, curLocation.protocol + "//");
//    return restPath(ol, src);
return restProtHost(ol, curLocation);
};


var menu = self.appendChild(document.createXULElement("menupopup"));
self.image = "moz-icon://file://" + path;
var playerName = path.split("\\").pop().replace(".exe","");
self.label = "Открыть видео в " +sysPlayerName;
setTimeout(() => {
Menu_n_TooltipTxts.forEach((m) => {
if("separator" in m) {
menu.appendChild(document.createXULElement("menuseparator"));
return
};
var mItem = document.createXULElement("menuitem");
mItem.setAttribute("label", m.label);

if("radio" in m) {
mItem.setAttribute("type", "radio");
mItem.setAttribute('checked', cbu.getPrefs("CB.video") == m.value);
if(cbu.getPrefs("CB.video") == m.value) {
self.tooltipText = m.tooltipTxt;
}
mItem.onclick = () => {
cbu.setPrefs("CB.video", m.value);
tmp = (self.image == imgFlashToPlayer || self.image == imgFlashMinimize ||  self.image == imgFlashMaximize);
if(m.value.substring(0,9)=='videotopl'){
self.image = tmp ? imgFlashToPlayer : imgHTML5ToPlayer;
} else if(m.value=='videominimize') {
self.image = tmp ? imgFlashMinimize : imgHTML5Minimize;
} else self.image = tmp ? imgFlashMaximize : imgHTML5Maximize;
self.tooltipText = m.tooltipTxt;
};
}
if("checkbox" in m) {
mItem.setAttribute('type', 'checkbox');
mItem.setAttribute('checked', (self.image == imgFlashToPlayer || self.image == imgFlashMinimize ||  self.image == imgFlashMaximize ));
mItem.onclick = function(e) {
e.stopPropagation();
e.preventDefault();
if(e.button == 0) toggleFlash();
}
}
menu.appendChild(mItem);
});
menu.onclick = function(e) {
e.stopPropagation();
if(e.button > 0) e.preventDefault();
};
}, 100);

var contextMenu = document.getElementById("contentAreaContextMenu"); 
var menuitem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-savelink"));
menuitem.setAttribute("label", "Открыть в " +sysPlayerName);      
menuitem.setAttribute("class", "menuitem-iconic");
menuitem.setAttribute("image", "moz-icon://file://" + path); 
menuitem.onclick = () => play(gContextMenu.linkURL);
addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink && !gContextMenu.onPlainTextLink, false, contextMenu);
addDestructor(()=> menuitem.remove() );
var contextMenu = document.getElementById("contentAreaContextMenu");
var mItem = contextMenu.insertBefore(document.createXULElement("menuitem"), document.getElementById("context-copyvideourl"));
mItem.setAttribute("label", openIn);
mItem.onclick = () => {
var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target;
if(videoelem && videoelem.nodeName.toLowerCase() == 'video') {
if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) {
play(vurl);
videoMovedbox = content.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>';
loadURI(stopPl);
content.document.getElementById('eow-title').appendChild(videoMovedbox);
return;
};

if(content.location.hostname == 'www.youtube.com') {
videoelem.parentNode.parentNode.appendChild(videoMovedbox);
} else {
var inFrameHref = inFrameWin.location.href, found = false;
if(inFrameWin.location.hostname == 'www.youtube.com' && (tmp = inFrameHref.match(YoutubeID)) && tmp[1].length == 11){//и значит во фрейме
elem = inFrameWin.parent.document.getElementsByTagName('iframe');
if(elem.length > 0) {
for(i = 0; i < elem.length; i++) {
if(elem[i].contentWindow == inFrameWin) {
elem[i].outerHTML = ytIMGouter(tmp[1]);
found = true;
break;
};
};
};
if(!found)inFrameWin.document.body.innerHTML = ytIMGouter(tmp[1]);
return;
};
videoelem.parentNode.appendChild(videoMovedbox);
};
videoelem.src = '';
try {
videoelem.load()
} catch(e) {};
} else play(vurl);
};


addEventListener("popupshowing", () => {
mItem.hidden = !gContextMenu.onVideo || !gContextMenu.mediaURL;
mItem2.hidden = !gContextMenu.linkURL;
mItem3.hidden = framItem.hidden || gContextMenu.target.ownerDocument.location.hostname.indexOf('youtube.com') == -1;
}, false, contextMenu);
addDestructor(() => {mItem.remove();mItem2.remove();mItem3.remove()});


function play(link) {
var file = Services.dirsvc.get('CurProcD', Ci.nsIFile);
var MozExeDir = file.path.split('\\').slice(0,-1).join('\\');
file.initWithPath(path);
if(!file.exists()) {
custombuttons.alertBox("File not found!", MozExeDir + Path);
return;
};
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, [link, cbu.getPrefs("CB.video") == "videotoplaylist" ? addToPlaylistKey : ""], 2);
};

Отсутствует

 

№1372913-09-2019 15:32:42

Garalf
Участник
 
Группа: Members
Зарегистрирован: 19-09-2017
Сообщений: 177
UA: Firefox 70.0

Re: Custom Buttons

И кнопка Autocopy тоже не работает в многопроцессорном режиме

скрытый текст

Выделить код

Код:

this.closest("toolbarpaletteitem") || (script => {
    var id = `CB${_id.slice(20)}:Autocopy`, pid = id + "Parent";
    var nsvoStr = `Components.utils.import("resource://gre/modules/Services.jsm", {})`;
    var nsvo = eval(nsvoStr), {Services} = nsvo, parent = nsvo[pid];
    if (!parent) {
        var cid = id + "Child", u = code => "data:," + encodeURIComponent(code);
        var pref = "CB.Autocopy.settings", topic = "quit-application-granted";
        var PREF_ENABLED = 1, PREF_BLINK = 2, PREF_RESET = 4;

        (parent = nsvo[pid] = {
            init() {
                this.readSettings();
                if (!this[PREF_ENABLED]) return;
                this.initChild();
                if (this[PREF_RESET]) this.setObserver(true);
            },
            destroy(reason) {
                var ud = reason[5] == "e";
                if (ud || !this.obsAdded) this.saveSettings();
                delete nsvo[pid];
                if (reason == "delete") Services.prefs.clearUserPref(pref);
                if (!this[PREF_ENABLED]) return;

                this.destroyChild();
                if (ud && this[PREF_RESET]) this.setObserver(false);
            },
            get processURL() {
                delete this.processURL;
                this.frameURL = u(`${nsvoStr}["${cid}"].init(this);`);
                return this.processURL = u(script.replace(/%ID%/g, cid)
                    .replace("%NSVO%", nsvoStr).replace("%BLINK%", this[PREF_BLINK])
                );
            },
            get frameURLDestroy() {
                delete this.frameURLDestroy;
                this.processURLDestroy = u(`${nsvoStr}["${cid}"].forget();`);
                return this.frameURLDestroy = u(`${nsvoStr}["${cid}"].destroy(this);`);
            },
            initChild() {
                Services.ppmm.loadProcessScript(this.processURL, true);
                Services.mm.loadFrameScript(this.frameURL, true);
            },
            destroyChild() {
                Services.mm.removeDelayedFrameScript(this.frameURL);
                Services.mm.loadFrameScript(this.frameURLDestroy, false);
                Services.ppmm.removeDelayedProcessScript(this.processURL);
                Services.ppmm.loadProcessScript(this.processURLDestroy, false);
            },
            readSettings() {
                this.prefVal = Services.prefs.getIntPref(pref, 3);
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    this[setting] = Boolean(this.prefVal & setting);
            },
            saveSettings() {
                var settings = 0;
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    if (this[setting]) settings += setting;
                if (this.prefVal != settings)
                    Services.prefs.setIntPref(pref, settings);
            },
            btns: new Set(),
            register(btn) {
                this.btns.add(btn);
                btn._handleClick = this.click;
                btn.oncontextmenu = this.context;
                this.setImg(btn, this[PREF_ENABLED]);
            },
            unregister(btn, reason) {
                this.btns.delete(btn);
                if (!this.btns.size) this.destroy(reason);
            },
            setImg(btn, state) {
                btn.ownerDocument.getAnonymousElementByAttribute(
                    btn, "class", "toolbarbutton-icon"
                ).src = state
                    ? "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgMBAAQIAAcEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAcACAMEAQEAAAAAAAAAAAAAAAACAwADAAAAABUnAB9cqgC3a7wB4Gq5Ad1qugHearoB3mq6Ad5qugHearoB3mi4AN1qugHgYrMAxR43AC8AAAAAAAEAAAECAAQAAAQAV6AAprP9Vv/W/qn80/+f/9T/ov/U/6L/1P+i/9T/ov/U/6L/1/+n/9X+pfy3/WL/Y7QAvwEAAQAAAAAAFSgAH1ehAKlyzwD1htgf/YzcJ/2K2yP9i9sk/YvbJf2L2yX9i9sm/YnaIv2b4kP92/21/Nf+qv9quwHdBQkACAAAAQBeqwCzr/tR/8X0j/u+8X//vvJ//77ygP++8oD/vvKA/77yf/+98n7/wvSH/4zcKv+e4kv93v+0/2i5AN0DBwAIBQkACGu8AdzV/af/4v/B/d//u//h/7//4f+//+H/v//h/7//4f+//9/+u//n/8n/w/GK/4zaK/3g/7r/aroC3gMHAAgEBwAIarkC3dX/pf/g/sD93v67/9/+vv/g/r//4P6//+D+v//f/r7/3f66/+T/xv/B8Yb/j9st/eT/w/9qugPeAwcACAQHAAhqugLe2v+w/+j/z/3l/8r/5//N/+f/zv/n/87/5//O/+f/zf/l/sj/7P/W/8Xyj/+Q2y/96f/N/2q6A94DBwAIBAcACGq6At7f/7n/7v/c/ev/1v/t/9n/7f/a/+3/2v/t/9r/7f/Z/+r+1f/y/+P/yPKW/5DbMf3s/9X/aroE3gMHAAgEBwAIaroC3uP/wf/z/+j98P/h//L/5P/z/+X/8//l//P/5f/y/+T/8P7g//j/7v/L8p3/kdsy/fD/3P9rugTeAwcACAQHAAhqugLe5v/J//j/8v31/+r/9v/t//f/7v/3/+//9//u//b/7f/0/un//f/4/87yo/+R2zL98f/f/2q5Bd0DBwAIBAcACGq6At7p/8///P/6/fj/8f/6//T/+v/1//r/9f/6//X/+v/0//f+8P//////0fGo/5PbNf30/+f/a7wE3AQJAAgEBwAIabkC3er/0f/+//79+v/0//v/9//8//j//P/4//z/+P/7//f/+f70///////T8qz/i9go+8P9ef9dqwCzAAACAAUJAAhquwHd7f7a//////z+//39/////f////3////9/////f////39/vz9/////dzzvv5v0AD1VqECqRUnAB8AAAAAAQACAGK0AL/J/Yf/8v7k/O3/1//u/9n/7v/Z/+7/2f/u/9n/7v/Z/+3/1//x/eP8vfxu/1WgAKYAAAUAAQIABAABAAAAAAAAHjcALmGzAMVquwLgarkC3Wq6At5qugLearoC3mq6At5qugLearkC3Wu8AeBbqgC3FScAHwAAAAACAwADAAAAAAAAAAAAAAAAAwQCAQQIAAgEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAgABwMDAgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                    : "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDAAQACAcEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAHCAMBBAEAAAAAAAAAAAAAAAACAAMDAAAAABUAJx9cAKq3awG84GoBud1qAbreagG63moBut5qAbreagG63mgAuN1qAbrgYgCzxR4ANy8AAAAAAAABAAEAAgQABAAAVwCgprNW/f/Wqf7805///9Si///Uov//1KL//9Si///Uov//16f//9Wl/vy3Yv3/YwC0vwEBAAAAAAAAFQAoH1cAoalyAM/1hh/Y/Ywn3P2KI9v9iyTb/Ysl2/2LJdv9iybb/Yki2v2bQ+L927X9/Neq/v9qAbvdBQAJCAABAABeAKuzr1H7/8WP9Pu+f/H/vn/y/76A8v++gPL/voDy/75/8v+9fvL/wof0/4wq3P+eS+L93rT//2gAud0DAAcIBQAJCGsBvNzVp/3/4sH//d+7///hv///4b///+G////hv///4b///9+7/v/nyf//w4rx/4wr2v3guv//agK63gMABwgEAAcIagK53dWl///gwP793rv+/9++/v/gv/7/4L/+/+C//v/fvv7/3br+/+TG///BhvH/jy3b/eTD//9qA7reAwAHCAQABwhqArre2rD//+jP//3lyv//583//+fO///nzv//587//+fN///lyP7/7Nb//8WP8v+QL9v96c3//2oDut4DAAcIBAAHCGoCut7fuf//7tz//evW///t2f//7dr//+3a///t2v//7dn//+rV/v/y4///yJby/5Ax2/3s1f//agS63gMABwgEAAcIagK63uPB///z6P/98OH///Lk///z5f//8+X///Pl///y5P//8OD+//ju///LnfL/kTLb/fDc//9rBLreAwAHCAQABwhqArre5sn///jy//316v//9u3///fu///37///9+7///bt///06f7//fj//86j8v+RMtv98d///2oFud0DAAcIBAAHCGoCut7pz////Pr//fjx///69P//+vX///r1///69f//+vT///fw/v//////0ajx/5M12/305///awS83AQACQgEAAcIaQK53erR///+/v/9+vT///v3///8+P///Pj///z4///79///+fT+///////TrPL/iyjY+8N5/f9dAKuzAAIAAAUACQhqAbvd7dr+//////z+/f/9/////f////3////9/////f////39/P79/////dy+8/5vAND1VgKhqRUAJx8AAAAAAQIAAGIAtL/Jh/3/8uT+/O3X///u2f//7tn//+7Z///u2f//7tn//+3X///x4/38vW78/1UAoKYABQAAAQACBAAAAQAAAAAAHgA3LmEAs8VqArvgagK53WoCut5qArreagK63moCut5qArreagK53WsBvOBbAKq3FQAnHwAAAAACAAMDAAAAAAAAAAAAAAAAAwIEAQQACAgEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAIBwMCAwAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
            },
            click() {
                var newState = parent[PREF_ENABLED] = !parent[PREF_ENABLED];
                for(var btn of parent.btns) parent.setImg(btn, newState);
                newState ? parent.initChild() : parent.destroyChild();
                if (parent[PREF_RESET]) parent.setObserver(newState);
            },
            context(e) {
                if (e.ctrlKey || e.shiftKey) return;
                if (e.detail > 1) return parent.popup.hidePopup();
                if (!this.contains(parent.popup)) this.appendChild(parent.popup);
                e.preventDefault();
                parent.popup.openPopup(this, "after_start");
            },
            get popup() {
                var win = Services.wm.getMostRecentWindow("navigator:browser");
                var doc = win.document, popup = doc.createElementNS(xulns,"menupopup");
                popup.setAttribute("onclick", "event.stopPropagation();");
                popup.setAttribute("oncommand", "handleCommand(event.target);");
                for(var [lab, pref] of win.Object.entries({
                    "Выделенный текст мигает при автокопировании": PREF_BLINK,
                    "Выключать автокопирование при выходе из браузера": PREF_RESET
                })) {
                    var menuitem = popup.appendChild(doc.createElementNS(xulns,"menuitem"));
                    menuitem.setAttribute("label", lab);
                    menuitem.setAttribute("type", "checkbox");
                    if (this[menuitem.pref = pref]) menuitem.setAttribute("checked", true);
                }
                popup.handleCommand = menuitem => {
                    var newState = this[menuitem.pref] = menuitem.hasAttribute("checked");
                    if (!this[PREF_ENABLED]) return;

                    if (menuitem.pref == PREF_BLINK)
                        Services.ppmm.broadcastAsyncMessage(cid + ":FromParent", {blink: newState});
                    else if (menuitem.pref == PREF_RESET)
                        this.setObserver(newState);
                }
                delete this.popup; return this.popup = popup;
            },
            obsAdded: false,
            setObserver(set) {this.obsAdded = set
                ? Services.obs.addObserver(this, topic, false)
                : Services.obs.removeObserver(this, topic);
            },
            observe() {
                Services.obs.removeObserver(this, topic);
                this[PREF_ENABLED] = false;
                this.saveSettings();
            }
        }).init();
    }
    parent.register(this);
    addDestructor(reason => parent.unregister(this, reason), parent);

})(`(nsvo => (nsvo["%ID%"] = {
    x: -1, y: -1, d: false,
    handleEvent(e) {e.button || this[e.type](e);},
    mousedown(e) {this.x = e.screenX; this.y = e.screenY, this.down = true;},
    mouseup(e) {
        var {down} = this; this.down = false; if (!down) return;
        if (e.screenX == this.x && e.screenY == this.y && (e.detail == 1 || e.target.matches(
            "textarea[disabled],input[disabled],button,select,summary"
        )))
            return;
        var name = e.originalTarget.nodeName;
        if (/^(?:(?:xul:)?(?:slider|scrollbarbutton)|resizer)$/.test(name))
            return;
        this.x = this.y = -1;
        var win = this.getFocusedWin(e.target.ownerGlobal);
        var sel = win.getSelection();
        if (sel.toString()) {
            (win.docShell || win.document.docShell).doCommand("cmd_copy", null, win);
            this.blinkEnabled && this.blink(win, e.detail > 1);
        }
    },
    blinkEnabled: %BLINK%,
    blink(win, pause) {
        if (pause) return win.setTimeout(() => this.blink(win), 100);
        var sc = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsIWebNavigation)
            .QueryInterface(Components.interfaces.nsIDocShell)
            .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsISelectionDisplay)
            .QueryInterface(Components.interfaces.nsISelectionController);
        sc.setDisplaySelection(sc.SELECTION_OFF);
        sc.repaintSelection(sc.SELECTION_NORMAL);
        win.setTimeout(() => {
            sc.setDisplaySelection(sc.SELECTION_ON);
            sc.repaintSelection(sc.SELECTION_NORMAL);
        }, 150);
    },
    getFocusedWin(win) {
        var focusedWin = {};
        var elm = Services.focus.getFocusedElementForWindow(win.top, true, focusedWin);
        return focusedWin.value;
    },
    get cm() {
        delete this.cm;
        return this.cm = Components.classes["@mozilla.org/embedcomp/command-manager;1"]
            .getService(Components.interfaces.nsICommandManager);
    },
    count: 0,
    init(cfmm) {
        this.count += 1;
        cfmm.addEventListener("mousedown", this);
        cfmm.addEventListener("mouseup", this);
        cfmm.addEventListener("unload", this);
        if (this.count == 1)
            this.cpmm.addMessageListener("%ID%:FromParent", this);
    },
    destroy(cfmm) {
        this.count -= 1;
        cfmm.removeEventListener("mousedown", this);
        cfmm.removeEventListener("mouseup", this);
        cfmm.removeEventListener("unload", this);
        if (!this.count)
            this.cpmm.removeMessageListener("%ID%:FromParent", this);
    },
    receiveMessage(msg) {
        if ("blink" in msg.data) this.blinkEnabled = msg.data.blink;
    },
    unload(e) {this.destroy(e.target);},
    forget: () => delete nsvo["%ID%"]

}).cpmm = this)(%NSVO%);`);


Если у кого-то есть, выложите, плиз
Еще одну кнрпку нужную и неработающую в многопроцессорном режиме нашел - Сохранить страницу как HTML
скрытый текст

Выделить код

Код:

var saveToFile = function (fileContent, fileName) {
        var uc = Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
        uc.charset = 'utf-8';
        fileContent = uc.ConvertFromUnicode(fileContent);

        var nsIFilePicker = Components.interfaces.nsIFilePicker;
        var fp = Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
        fp.init(window, '', fp.modeSave);
        fp.defaultString = fileName;
        fp.appendFilters(fp.filterHTML);
        fp.appendFilters(fp.filterAll);
        fp.open(function (rv) {
      if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
        var stream = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);
        stream.init(fp.file, 0x02|0x20|0x08, 0666, 0);
        stream.write(fileContent, fileContent.length);
        stream.close();
      }
    });

    };
    var resolveURL = function (url, base) {
        try {
            var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService);
            var baseURI = ioService.newURI(base, null, null);
            var absURI = ioService.newURI(url, null, baseURI);
            return absURI.spec;
        } catch (e) {}
    };

    var getSelWin = function (w) {
        if (w.getSelection().toString()) return w;
        for (var i = 0, f, r; f = w.frames[i]; i++) {
            try {
                if (r = getSelWin(f)) return r;
            } catch(e) {}
        }
    };
    var encodeImg = function (src, obj) {
        var canvas, img, ret = src;
        if (/^https?:\/\//.test(src)) {
            canvas = doc.createElement('canvas');
            if (!obj || obj.nodeName.toLowerCase() != 'img') {
                img = doc.createElement('img');
                img.src = src;
            } else {
                img = obj;
            };
            if (img.complete) try{
                canvas.width = img.width;
                canvas.height = img.height;
                canvas.getContext('2d').drawImage(img, 0, 0);
                ret = canvas.toDataURL((/\.jpe?g/i.test(src) ? 'image/jpeg' : 'image/png'));
            } catch (e) {};
            if (img != obj) img.src = 'about:blank';
        };
        return ret;
    };
    var toSrc = function (obj) {
        var strToSrc = function (str) {
            var chr, ret = '', i = 0, meta = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '\x22' : '\\\x22', '\\': '\\\\'};
            while (chr = str.charAt(i++)) {
                ret += meta[chr] || chr;
            };
            return '\x22' + ret + '\x22';
        },
        arrToSrc = function (arr) {
            var ret = [];
            for (var i = 0; i < arr.length; i++) {
                ret[i] = toSrc(arr[i]) || 'null';
            };
            return '[' + ret.join(',') + ']';
        },
        objToSrc = function (obj) {
            var val, ret = [];
            for (var prop in obj) {
                if (obj.hasOwnProperty(prop) && (val = toSrc(obj[prop]))) ret.push(strToSrc(prop) + ': ' + val);
            };
            return '{' + ret.join(',') + '}';
        };

        switch (Object.prototype.toString.call(obj).slice(8, -1)) {
            case 'Array': return arrToSrc(obj);
            case 'Boolean':
            case 'Function':
            case 'RegExp': return obj.toString();
            case 'Date': return 'new Date(' + obj.getTime() + ')';
            case 'Math': return 'Math';
            case 'Number': return isFinite(obj) ? String(obj) : 'null';
            case 'Object': return objToSrc(obj);
            case 'String': return strToSrc(obj);
            default: return obj ? (obj.nodeType == 1 && obj.id ? 'document.getElementById(' + strToSrc(obj.id) + ')' : '{}') : 'null';
        }
    };

    var mainWin = document.commandDispatcher.focusedWindow.top == content ? document.commandDispatcher.focusedWindow : content
    var selWin = getSelWin(mainWin), win = selWin || mainWin, doc = win.document, loc = win.location;
    var ele, pEle, clone, reUrl = /(url\(\x22)(.+?)(\x22\))/g;

    if (selWin) {
        var rng = win.getSelection().getRangeAt(0);
        pEle = rng.commonAncestorContainer;
        ele = rng.cloneContents();
    } else {
        pEle = doc.documentElement;
        ele = (doc.body || doc.getElementsByTagName('body')[0]).cloneNode(true);
    };
    while (pEle) {
        if (pEle.nodeType == 1) {
            clone = pEle.cloneNode(false);
            clone.appendChild(ele);
            ele = clone;
        };
        pEle = pEle.parentNode
    };
    var sel = doc.createElement('div');
    sel.appendChild(ele);

    for (var el, all = sel.getElementsByTagName('*'), i = all.length; i--;) {
        el = all[i];
        if (el.style && el.style.backgroundImage) el.style.backgroundImage = el.style.backgroundImage.replace(reUrl, function (a, prev, url, next) {
            if (!/^[a-z]+:/.test(url)) url = resolveURL(url, loc.href);
            return prev + encodeImg(url) + next;
        });
        switch (el.nodeName.toLowerCase()) {
            case 'link':
            case 'style':
            case 'script': el.parentNode.removeChild(el); break;
            case 'a': 
            case 'area': if (el.hasAttribute('href') && el.getAttribute('href').charAt(0) != '#') el.href = el.href; break;
            case 'img':
            case 'input': if (el.hasAttribute('src')) el.src = encodeImg(el.src, el); break;
            case 'audio':
            case 'video':
            case 'embed':
            case 'frame':
            case 'iframe': if (el.hasAttribute('src')) el.src = el.src; break;
            case 'object': if (el.hasAttribute('data')) el.data = el.data; break;
            case 'form': if (el.hasAttribute('action')) el.action = el.action; break;
        }
    };

    var head = ele.insertBefore(doc.createElement('head'), ele.firstChild);
    var meta = doc.createElement('meta');
    meta.httpEquiv = 'content-type';
    meta.content = 'text/html; charset=utf-8';
    head.appendChild(meta);
    var title = doc.getElementsByTagName('title')[0];
    if (title) head.appendChild(title.cloneNode(true));

    head.copyScript = function (unsafeWin) {
        if ('$' in unsafeWin) return;
        var f = doc.createElement('iframe');
        f.src = 'about:blank';
        f.setAttribute('style', 'position:fixed;left:0;top:0;visibility:hidden;width:0;height:0;');
        doc.documentElement.appendChild(f);
        var str, script = doc.createElement('script');
        script.type = 'text/javascript';
        for (var name in unsafeWin) {
            if (name in f.contentWindow || !/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name)) continue;
            try {
                str = toSrc(unsafeWin[name]);
                if (!/\{\s*\[native code\]\s*\}/.test(str)) {
                    script.appendChild(doc.createTextNode('var ' + name + ' = ' + str.replace(/<\/(script>)/ig, '<\\/$1') + ';\n'));
                }
            } catch (e) {};
        };
        f.parentNode.removeChild(f);
        if (script.childNodes.length) this.nextSibling.appendChild(script);
    };
    head.copyScript(win.wrappedJSObject || win);

    head.copyStyle = function (s) {
        if (!s) return;
        var style = doc.createElement('style');
        style.type = 'text/css';
        if (s.media && s.media.mediaText) style.media = s.media.mediaText;
        try {
            for (var i = 0, rule; rule = s.cssRules[i]; i++) {
                if (rule.type != 3) {
                    if((!rule.selectorText || rule.selectorText.indexOf(':') != -1) || (!sel.querySelector || sel.querySelector(rule.selectorText))) {
                        var css = !rule.cssText ? '' : rule.cssText.replace(reUrl, function (a, prev, url, next) {
                            if (!/^[a-z]+:/.test(url)) url = resolveURL(url, s.href || loc.href);
                            if(rule.type == 1 && rule.style && rule.style.backgroundImage) url = encodeImg(url);
                            return prev + url + next;
                        });
                        style.appendChild(doc.createTextNode(css + '\n'));
                    }
                } else {
                    this.copyStyle(rule.styleSheet);
                }
            }
        } catch(e) {
            if (s.ownerNode) style = s.ownerNode.cloneNode(false);
        };
        this.appendChild(style);
    };
    var sheets = doc.styleSheets;
    for (var j = 0; j < sheets.length; j++) head.copyStyle(sheets[j]);
    head.appendChild(doc.createTextNode('\n'));

    var doctype = '', 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 fileName = selWin ? win.getSelection().toString() : (title && title.text ? title.text : loc.pathname.split('/').pop());
    fileName = fileName.replace(/[:\\\/<>?*|"]+/g, '_').replace(/\s+/g, ' ').slice(0, 100).replace(/^\s+|\s+$/g, '');
    fileName += (function () {
        var d = new Date(), z = function(n){return '_' + (n < 10 ? '0' : '') + n};
        return z(d.getHours()) + z(d.getMinutes()) + z(d.getSeconds());
    })();
    if(!/\.html?$/.test(fileName))fileName += '.html';

    saveToFile(doctype + sel.innerHTML + '\n<!-- This document saved from ' + (loc.protocol != 'data:' ? loc.href : 'data:uri') + ' -->', fileName);


Может быть уважаемый Dumby сможет помочь

зы Обе кнопки в однопроцессорном режиме работают, а в многопроцессорном - нет.  FF 70b5

Отредактировано Garalf (13-09-2019 19:38:46)

Отсутствует

 

№1373013-09-2019 19:21:56

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 68.0

Re: Custom Buttons

Garalf

Garalf пишет:

зы Все эти кнопки работают в однопроцессорном режиме FF 70b5

Зы...А в каком не работают в однопроцессорном?

Отсутствует

 

№1373113-09-2019 19:25:58

Garalf
Участник
 
Группа: Members
Зарегистрирован: 19-09-2017
Сообщений: 177
UA: Firefox 70.0

Re: Custom Buttons

solombala
В однопроцессорном работают, а в многопроцессорном - нет, как и кнопка перенести видео в Pot

Отредактировано Garalf (13-09-2019 19:28:17)

Отсутствует

 

№1373213-09-2019 19:57:57

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 319
UA: unknown 0.0

Re: Custom Buttons

Dumby подскажи пожалуйста вот это патч Вы добавили в новую версию, что несколько страниц назад или нет, а то у меня без патча не хочет работать?
Да ещё вопрос у Вас кнопка - консоль браузера прежняя как для 68?

Garalf в этой кнопке один из пунктов сохранить как html

Отсутствует

 

№1373313-09-2019 19:58:39

Alewww
Участник
 
Группа: Members
Зарегистрирован: 31-01-2009
Сообщений: 12
UA: Firefox 69.0

Re: Custom Buttons

sn260591 пишет:

Alewww
Попробуй просто заменить nsILocalFile на nsIFile.

то что надо, спасибо!
вот еще (если кто будет искать после переезда на quantum):
Исправляем кнопки для перехода на сайт:
Было:

Выделить код

Код:

gBrowser.selectedTab = gBrowser.addTab(url);

Стало:

Выделить код

Код:

gBrowser.selectedTab = gBrowser.addTab(url, {
  triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});

url подставляем свой, в кавычках. пример кнопки:

Выделить код

Код:

gBrowser.selectedTab = gBrowser.addTab('https://www.google.com', {
  triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});

прошу прощения если было, но я немного обезкуражен после переезда с 56 мозиллы на quantum 69

может кто то сможет помочь с кнопкой, которая создает ярлык на сайт. К сожалению после переезда, она перестала работать.

Выделить код

Код:

// Создать кнопку ярлык для сайта, от 11.01.2015.


// Иконка для создания кнопки ярлыка без значка веб-сайта .................
var defaultFavicon = "chrome://custombuttons/skin/stdicons/gbutton.png";


// Получить иконку сайта и запустить создание кнопки ярлыка .................
PlacesUtils.favicons.getFaviconDataForPage(
      gBrowser.currentURI,
      function( uri, len, arr, mmt ) {
         if ( !len ) {
              createButton(defaultFavicon);
              return;
              }        
             
         // создать кнопку ярлык с значком веб-сайта( в base64 )     
         var base64 = "data:" + mmt + ";base64," + btoa(String.fromCharCode.apply(null, arr));
         createButton(base64);
      }   
);



// Дублировать кнопку и установить для новый кнопки иконку, название и код .................
function createButton(favicon) {  
   custombuttons.cloneButton(self);
   
   var newButtonLink = custombuttons.makeButtonLink("update", self.nextSibling.id || _id);
   var params = custombuttons.cbService.getButtonParameters(newButtonLink).wrappedJSObject;
   
   params.image = favicon;
   params.name = (content.document.title).substring(0, 75);
   params.code = "gBrowser.selectedTab = gBrowser.addTab('" + content.location + "');";
   
   params.wrappedJSObject = params;
   custombuttons.cbService.installButton(params);
};

Отсутствует

 

№1373413-09-2019 20:12:52

Garalf
Участник
 
Группа: Members
Зарегистрирован: 19-09-2017
Сообщений: 177
UA: Firefox 70.0

Re: Custom Buttons

Andrey_Krropotkin
Благодарю вас. Просто шикарно - все варианты сохранения работают.

Отредактировано Garalf (13-09-2019 20:16:36)

Отсутствует

 

№1373513-09-2019 20:56:18

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 209
UA: Firefox 60.0

Re: Custom Buttons

Есть кнопка чтобы переключаться между двумя вкладками которые посещались последними?

Отредактировано ifln (13-09-2019 21:18:40)

Отсутствует

 

№1373613-09-2019 21:19:24

Garalf
Участник
 
Группа: Members
Зарегистрирован: 19-09-2017
Сообщений: 177
UA: Firefox 70.0

Re: Custom Buttons

Dumby
Посмотрите, пожалуйста кнопку Autocopy https://forum.mozilla-russia.org/viewto … 68#p773268 (по-моему это ваш код)
Можно ли ее исправить для многопроцессорного режима?

Отредактировано Garalf (13-09-2019 21:20:41)

Отсутствует

 

№1373714-09-2019 01:54:51

func4ptch4
Участник
 
Группа: Members
Зарегистрирован: 03-05-2018
Сообщений: 144
UA: Firefox 69.0

Re: Custom Buttons

ifln

скрытый текст

Выделить код

Код:

//Ariadne.Flip
custombuttons.alertSlide1 = function(sTitle) {var as = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null);setTimeout(() => as.closeAlert(), 999);};
(()=> {var showCount = 0, noFlip = false, unlockTimer,lastShownTab = function() {let orderMax = 0,currentOrder = gBrowser.selectedTab.getAttribute('showOrder'),tabOrder = 0,
lST = null;currentOrder = currentOrder ? parseInt(currentOrder, 10) : 0;for(ii = 0; ii < gBrowser.tabs.length; ii++) {tabOrder = parseInt(gBrowser.tabs[ii].getAttribute('showOrder'), 10);
if(tabOrder != currentOrder){gBrowser.tabs[ii].removeAttribute('_YesClck');if(tabOrder > orderMax) {lST = gBrowser.tabs[ii];orderMax = tabOrder;}}};if(lST) return lST;
for(ii = 0; ii < gBrowser.tabs.length; ii++) {tabOrder = -parseInt(gBrowser.tabs[ii].getAttribute('showOrder'), 10);if(-tabOrder != currentOrder) {
gBrowser.tabs[ii].setAttribute('showOrder', tabOrder);if(tabOrder > orderMax) {lST = gBrowser.tabs[ii];orderMax = tabOrder;}}};return lST;};
function clickToFlip(event) {if(event.button || noFlip || !event.target.hasAttribute('_YesClck')) return;event.stopPropagation();event.target.removeAttribute('_YesClck');
let lShowT = lastShownTab();if(lShowT) {event.target.setAttribute('showOrder', -parseInt(event.target.getAttribute('showOrder'), 10));gBrowser.selectedTab = lShowT;} else {
setTimeout(() => custombuttons.alertSlide1("Нет других просмотренных ранее вкладок"), 100);setTimeout(() => gBrowser.selectedTab.setAttribute('_YesClck', true), 800);};};
function onTabClose(e) {if(gBrowser.selectedTab != e.target)return;let lastSh = lastShownTab();if(lastSh) gBrowser.selectedTab = lastSh;};
setTimeout(() => {if(gBrowser.selectedTab) {if(parseInt(gBrowser.selectedTab.getAttribute('showOrder'), 10) > 0) {showCount = parseInt(gBrowser.selectedTab.getAttribute('showOrder'), 10);
} else {gBrowser.selectedTab.setAttribute('showOrder', ++showCount);gBrowser.selectedTab.setAttribute('_YesClck', true);}};}, 800);
function onTabselect(e) {setTimeout(() => gBrowser.selectedTab.setAttribute('_YesClck', true), 150);for(ii = 0; ii < gBrowser.tabs.length; ii++)gBrowser.tabs[ii].removeAttribute('_YesClck');e.target.setAttribute('showOrder', ++showCount);};
function onMouseDown(e) {if(!e.target.hasAttribute('_YesClck')){noFlip = true;clearTimeout(unlockTimer);unlockTimer = setTimeout(function() {noFlip = false;clearTimeout(unlockTimer);}, 2000);}};
function onMouseUp(e) {clearTimeout(unlockTimer);setTimeout(() => noFlip = false, 100);};
addEventListener("mouseup", onMouseUp, false, gBrowser.tabContainer);addEventListener("mousedown", onMouseDown, false, gBrowser.tabContainer);
addEventListener("TabSelect", onTabselect, false, gBrowser.tabContainer);addEventListener("TabClose", onTabClose, false, gBrowser.tabContainer);
addEventListener("click", clickToFlip, false, gBrowser.tabContainer);addDestructor(()=>{removeEventListener("mouseup", onMouseUp, false, gBrowser.tabContainer);
removeEventListener("mousedown", onMouseDown, false, gBrowser.tabContainer);removeEventListener("TabSelect", onTabselect, false, gBrowser.tabContainer);
removeEventListener("TabClose", onTabClose, false, gBrowser.tabContainer);removeEventListener("click", clickToFlip, false, gBrowser.tabContainer);});})();


upd: Кликать надо по вкладке. (/*Initialization Code*/)

Отредактировано func4ptch4 (14-09-2019 10:38:00)

Отсутствует

 

№1373814-09-2019 06:40:21

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 209
UA: Firefox 60.0

Re: Custom Buttons

func4ptch4
Как это работает? Жму на кнопку, ничего не происходит. У меня 60ESR.
Можно без нотификации.

Кнопка должна переключать на предыдущую посещенную вкладку. По аналогии с быстрым переключением между двумя каналами в телевизоре.

Отредактировано ifln (14-09-2019 09:03:12)

Отсутствует

 

№1373914-09-2019 12:43:55

Dumby
Участник
 
Группа: Members
Зарегистрирован: 12-08-2012
Сообщений: 997
UA: Firefox 52.0

Re: Custom Buttons

Andrey_Krropotkin пишет:

патч Вы добавили в новую версию

Да, вроде добавлял, вернее оставил изменение.

без патча не хочет работать

Быть может это забывается, поэтому позволю себе напомнить, что
Firefox не предназначен для установки расширений, а это значит,
что если накатить новую версию поверх старой, то следует помочь
расширению актуализироваться перезапустив браузер с очисткой startupCache.

Можно при закрытом Firefox удалить содержимое этой папки вручную.
(она находится в локальном каталоге профиля)
А можно, повторюсь, перезапустить кодом, например таким:
Services.appinfo.invalidateCachesOnRestart();
BrowserUtils.restartApplication();

Надеюсь дело в этом.

у Вас кнопка - консоль браузера прежняя как для 68?

Ой, не помню уже. Давай просто скину из 71 как есть

скрытый текст

Выделить код

Код:

({
    title: "Консоль браузера",
    url: "chrome://devtools/content/webconsole/index.html",
    icon: "chrome://devtools/skin/images/tool-webconsole.svg",
    init() {
        var trg = document.getElementById("browser");
        trg && addEventListener("DOMContentLoaded", this, false, trg);
        var id = "viewBrowserConsoleSidebar";

        var menuitem = this.element("menuitem", {
            type: "checkbox",
            label: this.title,
            id: "menu_browserConsoleSidebar",
            oncommand: `SidebarUI.toggle("${id}");`
        }, document.getElementById("viewSidebarMenu"));

        var btn = this.element("toolbarbutton", {
            type: "checkbox",
            label: this.title,
            id: "sidebar-switcher-browserConsole",
            oncommand: `SidebarUI.show("${id}");`,
            class: "subviewbutton subviewbutton-iconic"
        });
        document.querySelector(
            'toolbarbutton[id^="sidebar-switcher-"] + toolbarseparator'
        ).before(btn);

        SidebarUI.sidebars.set(id, {
            url: this.url,
            buttonId: btn.id,
            title: this.title,
            menuId: menuitem.id
        });
        SidebarUI.isOpen && SidebarUI.currentID == id && SidebarUI.selectMenuItem(id);

        var popupset = this.popupset = this.element("popupset", {
            id: `CB${_id.slice(20)}-browserConsole-popupset`
        }, document.documentElement);

        var css = `\
            #${btn.id} > .toolbarbutton-icon,
            #sidebar-box[sidebarcommand="${id}"] > #sidebar-header > #sidebar-switcher-target > #sidebar-icon {
                list-style-image: url(${this.icon});
            }`;
        var str = "data:text/css," + encodeURIComponent(css), type = windowUtils.USER_SHEET;
        windowUtils.loadSheetUsingURIString(str, type);

        addDestructor(() => {
            SidebarUI.sidebars.delete(id);
            btn.remove(); menuitem.remove(); popupset.remove();
            windowUtils.removeSheetUsingURIString(str, type);
        });
        "insertFTLIfNeeded" in MozXULElement && MozXULElement
            .insertFTLIfNeeded("toolkit/main-window/editmenu.ftl");

        self.onclick = e => {
            if (e.button == 2) return;
            if (!e.button) return SidebarUI.toggle(id);
            var st = gBrowser.selectedTab, tab;
            if (!e.ctrlKey) tab = gBrowser.visibleTabs.find(tab => {
                var br = gBrowser.getBrowserForTab(tab);
                return br.currentURI.spec == this.url || (
                    "_cachedCurrentURI" in br
                    && br._cachedCurrentURI.spec == this.url
                )
            });
            if (tab == st) return;
            if (!tab) tab = gBrowser.addTrustedTab(this.url);
            gBrowser.moveTabTo(tab, st._tPos + 1);
            gBrowser.selectedTab = tab;
        }
        for(var br of gBrowser.browsers) {
            if (br.currentURI.spec != this.url) continue;
            var doc = br.contentDocument;
            if (doc && (
                doc.readyState == "complete" ||
                doc.readyState == "interactive"
            ))
                doc.querySelector(
                    "main#app-wrapper,div#output-container"
                ).childElementCount
                    ? this.defineDocPopupset(doc)
                    : this.handleEvent({target: doc});
        }
        if (!btn.hasAttribute("checked")) return;
        var doc = SidebarUI.browser.contentDocument;
        if (doc.documentURI != this.url) btn.doCommand();
        else if (doc.readyState == "complete") this.defineDocPopupset(doc);
    },
    defineDocPopupset(doc) {
        this.definePopupset(
            doc.querySelector("popupset") ||
            doc.documentElement.appendChild(doc.createXULElement("popupset"))
        );
    },
    get definePopupset() {
        var append = customElements.get("menuitem")
            ? popup => {
                this.popupset.appendChild(popup);
                popup.setAttribute("oncommand", "event.target.cmd()");
                for(var node of [...popup.querySelectorAll("menuitem")]) {
                    var menuitem = document.importNode(node, true);
                    menuitem.cmd = Services.els.getListenerInfoFor(node)
                        .find(inf => inf.type == "command").listenerObject;
                    popup.replaceChild(menuitem, node);
                }
                return popup;
            }
            : this.popupset.appendChild.bind(this.popupset);

        delete this.definePopupset;
        return this.definePopupset = popupset => popupset.appendChild = append;
    },
    async handleEvent({target: doc}) {
        if (!doc || Cu.isCrossProcessWrapper(doc) || doc.documentURI != this.url) return;

        var win = doc.defaultView;
        if (
            win.docShell.name == "toolbox-panel-iframe-webconsole" ||
            doc.DOMContentLoadedEventHandled
        )
            return;
        doc.DOMContentLoadedEventHandled = true;
        "custombuttonsConsole" in win || Services.scriptloader.loadSubScript(
            "chrome://custombuttons/content/consoleOverlay.js", win
        );
        var cw = win.isChromeWindow;
        if (!cw && doc.visibilityState == "hidden") {
            var {focus} = win;
            win.focus = () => win.focus = focus;
        }
        this.loader.Services.ww.wins.push(win);
        var bc = await new this.loader.HUDService().toggleBrowserConsole();
        this.defineDocPopupset(doc);
        if (cw) return;

        var br = win.docShell.chromeEventHandler;
        var cmAttr = br.getAttribute("contextmenu");
        cmAttr && br.removeAttribute("contextmenu");
        win.onbeforeunload = () => {
            bc.chromeWindow = {close() {}};
            cmAttr && br.setAttribute("contextmenu", cmAttr);
        }
        var link = doc.createElement("link");
        link.setAttribute("rel", "shortcut icon");
        link.setAttribute("href", this.icon);
        doc.head.prepend(link);
    },
    get loader() {
        delete this.loader;
        var id = _id + "-browser-console";
        var url = "resource://devtools/shared/Loader.jsm?" + id;
        var loader = {exports: {}}, nsvo = Cu.import(url, loader);
        addDestructor(reason => reason[5] == "e" && Cu.unload(url));

        if (id in nsvo) return this.loader = nsvo[id];

        var dir = "resource://devtools/client/webconsole/";
        var lss = Services.scriptloader.loadSubScript;
        try {
            lss(dir + "hudservice.js", loader);
        } catch(ex) {
            // Bug 1570320 - Rename hudservice.js into browser-console-manager.js (Firefox 70+)
            // https://bugzilla.mozilla.org/show_bug.cgi?id=1570320
            lss(dir + "browser-console-manager.js", loader);
            lss("data:,this.HUDService=BrowserConsoleManager", loader);
        }
        var e = new CustomEvent("DOMContentLoaded", {bubbles: false}), ww = loader.Services.ww;
        loader.Services.ww = Cu.getGlobalForObject(nsvo).Object.create(ww, {
            wins: {value: []},
            openWindow: {value: function() {
                var win = this.wins.shift();
                win.setTimeout(() => win.dispatchEvent(e), 0);
                return win;
            }}
        });
        return this.loader = nsvo[id] = loader;
    },
    element(name, attrs, parent) {
        var node = document.createXULElement(name);
        for(var attr in attrs) node.setAttribute(attr, attrs[attr]);
        parent && parent.append(node);
        return node;
    }
}).init();


Alewww пишет:

может кто то сможет помочь с кнопкой, которая создает ярлык на сайт

Не исключено

скрытый текст

Выделить код

Код:

// Иконка для создания кнопки ярлыка без значка веб-сайта .................
var defaultFavicon = "chrome://custombuttons/skin/stdicons/gbutton.png";


// Получить иконку сайта и запустить создание кнопки ярлыка .................
PlacesUtils.favicons.getFaviconDataForPage(
    gBrowser.currentURI,
    (uri, len, arr, mmt) => createButton(len
        ? `data:${mmt};base64,${btoa(String.fromCharCode(...arr))}`
        : defaultFavicon
    )
);

// Дублировать кнопку и установить для новый кнопки иконку, название и код .................
function createButton(favicon) {  
    custombuttons.cloneButton(self, true);

    var newButtonLink = custombuttons.makeButtonLink("update", self.nextSibling.id);
    var params = custombuttons.cbService.getButtonParameters(newButtonLink).wrappedJSObject;

    params.image = favicon;
    params.name = gBrowser.contentTitle.slice(0, 75);
    params.code = `gBrowser.selectedTab = gBrowser.addTrustedTab("${gBrowser.currentURI.spec}");`;

    custombuttons.cbService.installButton(params.wrappedJSObject = params);
}


Garalf пишет:

Посмотрите, пожалуйста кнопку Autocopy

OK, попробую. Рестарт.

скрытый текст

Выделить код

Код:

this.closest("toolbarpaletteitem") || (script => {
    var id = `CB${_id.slice(20)}:Autocopy`, pid = id + "Parent";
    var nsvoStr = `Components.utils.import("resource://gre/modules/Services.jsm", {})`;
    var nsvo = eval(nsvoStr), {Services} = nsvo, parent = nsvo[pid];
    if (!parent) {
        var cid = id + "Child", u = code => "data:," + encodeURIComponent(code);
        var pref = "CB.Autocopy.settings", topic = "quit-application-granted";
        var PREF_ENABLED = 1, PREF_BLINK = 2, PREF_RESET = 4;

        (parent = nsvo[pid] = {
            init() {
                this.readSettings();
                if (!this[PREF_ENABLED]) return;
                this.initChild();
                if (this[PREF_RESET]) this.setObserver(true);
            },
            destroy(reason) {
                var ud = reason[5] == "e";
                if (ud || !this.obsAdded) this.saveSettings();
                delete nsvo[pid];
                if (reason == "delete") Services.prefs.clearUserPref(pref);
                if (!this[PREF_ENABLED]) return;

                this.destroyChild();
                if (ud && this[PREF_RESET]) this.setObserver(false);
            },
            get processURL() {
                delete this.processURL;
                this.frameURL = u(`${nsvoStr}["${cid}"].init(this);`);
                return this.processURL = u(script.replace(/%ID%/g, cid)
                    .replace("%NSVO%", nsvoStr)
                    .replace("%PREF%", pref)
                    .replace("%PREF_BLINK%", PREF_BLINK)
                );
            },
            get frameURLDestroy() {
                delete this.frameURLDestroy;
                this.processURLDestroy = u(`${nsvoStr}["${cid}"].forget();`);
                return this.frameURLDestroy = u(`${nsvoStr}["${cid}"].destroy(this);`);
            },
            initChild() {
                Services.ppmm.loadProcessScript(this.processURL, true);
                Services.mm.loadFrameScript(this.frameURL, true);
            },
            destroyChild() {
                Services.mm.removeDelayedFrameScript(this.frameURL);
                Services.mm.loadFrameScript(this.frameURLDestroy, false);
                Services.ppmm.removeDelayedProcessScript(this.processURL);
                Services.ppmm.loadProcessScript(this.processURLDestroy, false);
            },
            readSettings() {
                var val = Services.prefs.getIntPref(pref, 3);
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    this[setting] = Boolean(val & setting);
            },
            saveSettings() {
                var settings = 0;
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    if (this[setting]) settings += setting;
                Services.prefs.setIntPref(pref, settings);
            },
            btns: new Set(),
            register(btn) {
                this.btns.add(btn);
                btn._handleClick = this.click;
                btn.oncontextmenu = this.context;
                this.setImg(btn, this[PREF_ENABLED]);
            },
            unregister(btn, reason) {
                this.btns.delete(btn);
                if (!this.btns.size) this.destroy(reason);
            },
            setImg(btn, state) {
                (btn.icon || btn.ownerDocument.getAnonymousElementByAttribute(
                    btn, "class", "toolbarbutton-icon"
                )).src = state
                    ? "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgMBAAQIAAcEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAcACAMEAQEAAAAAAAAAAAAAAAACAwADAAAAABUnAB9cqgC3a7wB4Gq5Ad1qugHearoB3mq6Ad5qugHearoB3mi4AN1qugHgYrMAxR43AC8AAAAAAAEAAAECAAQAAAQAV6AAprP9Vv/W/qn80/+f/9T/ov/U/6L/1P+i/9T/ov/U/6L/1/+n/9X+pfy3/WL/Y7QAvwEAAQAAAAAAFSgAH1ehAKlyzwD1htgf/YzcJ/2K2yP9i9sk/YvbJf2L2yX9i9sm/YnaIv2b4kP92/21/Nf+qv9quwHdBQkACAAAAQBeqwCzr/tR/8X0j/u+8X//vvJ//77ygP++8oD/vvKA/77yf/+98n7/wvSH/4zcKv+e4kv93v+0/2i5AN0DBwAIBQkACGu8AdzV/af/4v/B/d//u//h/7//4f+//+H/v//h/7//4f+//9/+u//n/8n/w/GK/4zaK/3g/7r/aroC3gMHAAgEBwAIarkC3dX/pf/g/sD93v67/9/+vv/g/r//4P6//+D+v//f/r7/3f66/+T/xv/B8Yb/j9st/eT/w/9qugPeAwcACAQHAAhqugLe2v+w/+j/z/3l/8r/5//N/+f/zv/n/87/5//O/+f/zf/l/sj/7P/W/8Xyj/+Q2y/96f/N/2q6A94DBwAIBAcACGq6At7f/7n/7v/c/ev/1v/t/9n/7f/a/+3/2v/t/9r/7f/Z/+r+1f/y/+P/yPKW/5DbMf3s/9X/aroE3gMHAAgEBwAIaroC3uP/wf/z/+j98P/h//L/5P/z/+X/8//l//P/5f/y/+T/8P7g//j/7v/L8p3/kdsy/fD/3P9rugTeAwcACAQHAAhqugLe5v/J//j/8v31/+r/9v/t//f/7v/3/+//9//u//b/7f/0/un//f/4/87yo/+R2zL98f/f/2q5Bd0DBwAIBAcACGq6At7p/8///P/6/fj/8f/6//T/+v/1//r/9f/6//X/+v/0//f+8P//////0fGo/5PbNf30/+f/a7wE3AQJAAgEBwAIabkC3er/0f/+//79+v/0//v/9//8//j//P/4//z/+P/7//f/+f70///////T8qz/i9go+8P9ef9dqwCzAAACAAUJAAhquwHd7f7a//////z+//39/////f////3////9/////f////39/vz9/////dzzvv5v0AD1VqECqRUnAB8AAAAAAQACAGK0AL/J/Yf/8v7k/O3/1//u/9n/7v/Z/+7/2f/u/9n/7v/Z/+3/1//x/eP8vfxu/1WgAKYAAAUAAQIABAABAAAAAAAAHjcALmGzAMVquwLgarkC3Wq6At5qugLearoC3mq6At5qugLearkC3Wu8AeBbqgC3FScAHwAAAAACAwADAAAAAAAAAAAAAAAAAwQCAQQIAAgEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAgABwMDAgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                    : "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDAAQACAcEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAHCAMBBAEAAAAAAAAAAAAAAAACAAMDAAAAABUAJx9cAKq3awG84GoBud1qAbreagG63moBut5qAbreagG63mgAuN1qAbrgYgCzxR4ANy8AAAAAAAABAAEAAgQABAAAVwCgprNW/f/Wqf7805///9Si///Uov//1KL//9Si///Uov//16f//9Wl/vy3Yv3/YwC0vwEBAAAAAAAAFQAoH1cAoalyAM/1hh/Y/Ywn3P2KI9v9iyTb/Ysl2/2LJdv9iybb/Yki2v2bQ+L927X9/Neq/v9qAbvdBQAJCAABAABeAKuzr1H7/8WP9Pu+f/H/vn/y/76A8v++gPL/voDy/75/8v+9fvL/wof0/4wq3P+eS+L93rT//2gAud0DAAcIBQAJCGsBvNzVp/3/4sH//d+7///hv///4b///+G////hv///4b///9+7/v/nyf//w4rx/4wr2v3guv//agK63gMABwgEAAcIagK53dWl///gwP793rv+/9++/v/gv/7/4L/+/+C//v/fvv7/3br+/+TG///BhvH/jy3b/eTD//9qA7reAwAHCAQABwhqArre2rD//+jP//3lyv//583//+fO///nzv//587//+fN///lyP7/7Nb//8WP8v+QL9v96c3//2oDut4DAAcIBAAHCGoCut7fuf//7tz//evW///t2f//7dr//+3a///t2v//7dn//+rV/v/y4///yJby/5Ax2/3s1f//agS63gMABwgEAAcIagK63uPB///z6P/98OH///Lk///z5f//8+X///Pl///y5P//8OD+//ju///LnfL/kTLb/fDc//9rBLreAwAHCAQABwhqArre5sn///jy//316v//9u3///fu///37///9+7///bt///06f7//fj//86j8v+RMtv98d///2oFud0DAAcIBAAHCGoCut7pz////Pr//fjx///69P//+vX///r1///69f//+vT///fw/v//////0ajx/5M12/305///awS83AQACQgEAAcIaQK53erR///+/v/9+vT///v3///8+P///Pj///z4///79///+fT+///////TrPL/iyjY+8N5/f9dAKuzAAIAAAUACQhqAbvd7dr+//////z+/f/9/////f////3////9/////f////39/P79/////dy+8/5vAND1VgKhqRUAJx8AAAAAAQIAAGIAtL/Jh/3/8uT+/O3X///u2f//7tn//+7Z///u2f//7tn//+3X///x4/38vW78/1UAoKYABQAAAQACBAAAAQAAAAAAHgA3LmEAs8VqArvgagK53WoCut5qArreagK63moCut5qArreagK53WsBvOBbAKq3FQAnHwAAAAACAAMDAAAAAAAAAAAAAAAAAwIEAQQACAgEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAIBwMCAwAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
            },
            click() {
                var newState = parent[PREF_ENABLED] = !parent[PREF_ENABLED];
                for(var btn of parent.btns) parent.setImg(btn, newState);
                newState ? parent.initChild() : parent.destroyChild();
                if (parent[PREF_RESET]) parent.setObserver(newState);
            },
            context(e) {
                if (e.ctrlKey || e.shiftKey) return;
                var btn = e.target;
                if (btn.btnPopup && e.detail > 1) return btn.btnPopup.hidePopup();
                e.preventDefault();
                (btn.btnPopup || parent.getPopup(btn)).openPopup(btn, "after_start");
            },
            getPopup(btn) {
                var win = btn.ownerGlobal, doc = win.document;
                var popup = doc.createElementNS(xulns, "menupopup");
                popup.setAttribute("onclick", "event.stopPropagation();");
                popup.setAttribute("oncommand", "handleCommand(event.target);");
                popup.setAttribute("onpopupshowing", "handlePopupshowing();");
                popup.menuitems = [];
                for(var [lab, pref] of win.Object.entries({
                    "Выделенный текст мигает при автокопировании": PREF_BLINK,
                    "Выключать автокопирование при выходе из браузера": PREF_RESET
                })) {
                    var menuitem = popup.appendChild(doc.createElementNS(xulns, "menuitem"));
                    menuitem.setAttribute("label", lab);
                    menuitem.setAttribute("type", "checkbox");
                    menuitem.pref = pref;
                    popup.menuitems.push(menuitem);
                }
                popup.handleCommand = menuitem => {
                    var newState = this[menuitem.pref] = menuitem.hasAttribute("checked");
                    if (!this[PREF_ENABLED]) return;

                    if (menuitem.pref == PREF_BLINK)
                        this.saveSettings(),
                        Services.ppmm.broadcastAsyncMessage(cid + ":FromParent", {blink: newState});
                    else if (menuitem.pref == PREF_RESET)
                        this.setObserver(newState);
                }
                popup.handlePopupshowing = () => {
                    for(var menuitem of popup.menuitems) this[menuitem.pref]
                        ? menuitem.setAttribute("checked", true)
                        : menuitem.removeAttribute("checked");
                }
                return btn.appendChild(btn.btnPopup = popup);
            },
            obsAdded: false,
            setObserver(set) {this.obsAdded = set
                ? Services.obs.addObserver(this, topic, false)
                : Services.obs.removeObserver(this, topic);
            },
            observe() {
                Services.obs.removeObserver(this, topic);
                this[PREF_ENABLED] = false;
                this.saveSettings();
            }
        }).init();
    }
    parent.register(this);
    addDestructor(reason => parent.unregister(this, reason), parent);

})(`(nsvo => (nsvo["%ID%"] = {
    x: -1, y: -1, down: false,
    handleEvent(e) {e.button || this[e.type](e);},
    mousedown(e) {this.x = e.screenX; this.y = e.screenY, this.down = true;},
    mouseup(e) {
        var {down} = this; this.down = false; if (!down) return;
        if (e.screenX == this.x && e.screenY == this.y && (e.detail == 1 || e.target.matches(
            "textarea[disabled],input[disabled],button,select,summary"
        )))
            return;
        var name = e.originalTarget.nodeName;
        if (/^(?:(?:xul:)?(?:slider|scrollbarbutton)|resizer)$/.test(name))
            return;
        this.x = this.y = -1;
        var win = this.getFocusedWin(e.target.ownerGlobal);
        var sel = win.getSelection();
        if (sel.toString()) {
            (win.docShell || win.document.docShell).doCommand("cmd_copy", null, win);
            this.blinkEnabled && this.blink(win, e.detail > 1);
        }
    },
    blinkEnabled: Boolean(
        Components.classes["@mozilla.org/preferences-service;1"]
            .getService(Components.interfaces.nsIPrefService)
            .getIntPref("%PREF%", 3) & %PREF_BLINK%
    ),
    blink(win, pause) {
        if (pause) return win.setTimeout(() => this.blink(win), 100);
        var sc = (win.docShell || win.document.docShell)
            .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsISelectionDisplay)
            .QueryInterface(Components.interfaces.nsISelectionController);
        sc.setDisplaySelection(sc.SELECTION_OFF);
        sc.repaintSelection(sc.SELECTION_NORMAL);
        win.setTimeout(() => {
            sc.setDisplaySelection(sc.SELECTION_ON);
            sc.repaintSelection(sc.SELECTION_NORMAL);
        }, 150);
    },
    getFocusedWin(win) {
        var focusedWin = {};
        var elm = this.fm.getFocusedElementForWindow(win.top, true, focusedWin);
        return focusedWin.value;
    },
    get fm() {
        delete this.fm;
        return this.fm = Components.classes["@mozilla.org/focus-manager;1"]
            .getService(Components.interfaces.nsIFocusManager);
    },
    count: 0,
    init(cfmm) {
        this.count += 1;
        cfmm.addEventListener("mousedown", this);
        cfmm.addEventListener("mouseup", this);
        cfmm.addEventListener("unload", this);
        if (this.count == 1)
            this.cpmm.addMessageListener("%ID%:FromParent", this);
    },
    destroy(cfmm) {
        this.count -= 1;
        cfmm.removeEventListener("mousedown", this);
        cfmm.removeEventListener("mouseup", this);
        cfmm.removeEventListener("unload", this);
        if (!this.count)
            this.cpmm.removeMessageListener("%ID%:FromParent", this);
    },
    receiveMessage(msg) {
        if ("blink" in msg.data) this.blinkEnabled = msg.data.blink;
    },
    unload(e) {this.destroy(e.target);},
    forget: () => delete nsvo["%ID%"]

}).cpmm = this)(%NSVO%);`);


ifln пишет:

Кнопка должна переключать на предыдущую посещенную вкладку. По аналогии с быстрым переключением между двумя каналами в телевизоре.

Может так сойдёт. На группировщик вкладок не рассчитано,
но раз не упомянут, значит не используется, логично же.

скрытый текст

Выделить код

Код:

(dummy => {
    var getTab = () => {
        var tab = dummy;
        for(var t of gBrowser.tabs)
            if (!t.closing && !t.selected && t.lastAccessed > tab.lastAccessed)
                tab = t;
        return tab == dummy ? gBrowser.selectedTab : tab;
    }
    var tabToSelect = dummy;
    addDestructor(() => tabToSelect = null);
    this._handleClick = () => gBrowser.selectedTab =
        tabToSelect.parentNode && !tabToSelect.closing ? tabToSelect : getTab();
    addEventListener("TabSelect", e => tabToSelect = e.detail.previousTab, false, gBrowser.tabContainer || 1);
})({lastAccessed: 0});

Отсутствует

 

№1374014-09-2019 13:19:55

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 209
UA: Firefox 60.0

Re: Custom Buttons

func4ptch4 пишет:

Кликать надо по вкладке. (/*Initialization Code*/)

Пример, кликаю по вкладке Б и открывается вкладка А. Дальнейшие клики по Б правильно перемещают туда-обратно.
Но если затем кликнуть по активной вкладке А, открывается не Б, другая. Возможно та, которая была активной перед первым открытием вкладки А.

Dumby
Отлично. Спасибо!

Отредактировано ifln (14-09-2019 13:22:34)

Отсутствует

 

№1374114-09-2019 13:33:08

Garalf
Участник
 
Группа: Members
Зарегистрирован: 19-09-2017
Сообщений: 177
UA: Firefox 70.0

Re: Custom Buttons

Dumby
Очередное Спасибо!

Для всех! Кнопка Autocopy от Dumby для FF66+, работающая в одно- и многопроцессорном режимах

скрытый текст

Выделить код

Код:

this.closest("toolbarpaletteitem") || (script => {
    var id = `CB${_id.slice(20)}:Autocopy`, pid = id + "Parent";
    var nsvoStr = `Components.utils.import("resource://gre/modules/Services.jsm", {})`;
    var nsvo = eval(nsvoStr), {Services} = nsvo, parent = nsvo[pid];
    if (!parent) {
        var cid = id + "Child", u = code => "data:," + encodeURIComponent(code);
        var pref = "CB.Autocopy.settings", topic = "quit-application-granted";
        var PREF_ENABLED = 1, PREF_BLINK = 2, PREF_RESET = 4;

        (parent = nsvo[pid] = {
            init() {
                this.readSettings();
                if (!this[PREF_ENABLED]) return;
                this.initChild();
                if (this[PREF_RESET]) this.setObserver(true);
            },
            destroy(reason) {
                var ud = reason[5] == "e";
                if (ud || !this.obsAdded) this.saveSettings();
                delete nsvo[pid];
                if (reason == "delete") Services.prefs.clearUserPref(pref);
                if (!this[PREF_ENABLED]) return;

                this.destroyChild();
                if (ud && this[PREF_RESET]) this.setObserver(false);
            },
            get processURL() {
                delete this.processURL;
                this.frameURL = u(`${nsvoStr}["${cid}"].init(this);`);
                return this.processURL = u(script.replace(/%ID%/g, cid)
                    .replace("%NSVO%", nsvoStr)
                    .replace("%PREF%", pref)
                    .replace("%PREF_BLINK%", PREF_BLINK)
                );
            },
            get frameURLDestroy() {
                delete this.frameURLDestroy;
                this.processURLDestroy = u(`${nsvoStr}["${cid}"].forget();`);
                return this.frameURLDestroy = u(`${nsvoStr}["${cid}"].destroy(this);`);
            },
            initChild() {
                Services.ppmm.loadProcessScript(this.processURL, true);
                Services.mm.loadFrameScript(this.frameURL, true);
            },
            destroyChild() {
                Services.mm.removeDelayedFrameScript(this.frameURL);
                Services.mm.loadFrameScript(this.frameURLDestroy, false);
                Services.ppmm.removeDelayedProcessScript(this.processURL);
                Services.ppmm.loadProcessScript(this.processURLDestroy, false);
            },
            readSettings() {
                var val = Services.prefs.getIntPref(pref, 3);
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    this[setting] = Boolean(val & setting);
            },
            saveSettings() {
                var settings = 0;
                for(var setting of [PREF_ENABLED, PREF_BLINK, PREF_RESET])
                    if (this[setting]) settings += setting;
                Services.prefs.setIntPref(pref, settings);
            },
            btns: new Set(),
            register(btn) {
                this.btns.add(btn);
                btn._handleClick = this.click;
                btn.oncontextmenu = this.context;
                this.setImg(btn, this[PREF_ENABLED]);
            },
            unregister(btn, reason) {
                this.btns.delete(btn);
                if (!this.btns.size) this.destroy(reason);
            },
            setImg(btn, state) {
                (btn.icon || btn.ownerDocument.getAnonymousElementByAttribute(
                    btn, "class", "toolbarbutton-icon"
                )).src = state
                    ? "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgMBAAQIAAcEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAcACAMEAQEAAAAAAAAAAAAAAAACAwADAAAAABUnAB9cqgC3a7wB4Gq5Ad1qugHearoB3mq6Ad5qugHearoB3mi4AN1qugHgYrMAxR43AC8AAAAAAAEAAAECAAQAAAQAV6AAprP9Vv/W/qn80/+f/9T/ov/U/6L/1P+i/9T/ov/U/6L/1/+n/9X+pfy3/WL/Y7QAvwEAAQAAAAAAFSgAH1ehAKlyzwD1htgf/YzcJ/2K2yP9i9sk/YvbJf2L2yX9i9sm/YnaIv2b4kP92/21/Nf+qv9quwHdBQkACAAAAQBeqwCzr/tR/8X0j/u+8X//vvJ//77ygP++8oD/vvKA/77yf/+98n7/wvSH/4zcKv+e4kv93v+0/2i5AN0DBwAIBQkACGu8AdzV/af/4v/B/d//u//h/7//4f+//+H/v//h/7//4f+//9/+u//n/8n/w/GK/4zaK/3g/7r/aroC3gMHAAgEBwAIarkC3dX/pf/g/sD93v67/9/+vv/g/r//4P6//+D+v//f/r7/3f66/+T/xv/B8Yb/j9st/eT/w/9qugPeAwcACAQHAAhqugLe2v+w/+j/z/3l/8r/5//N/+f/zv/n/87/5//O/+f/zf/l/sj/7P/W/8Xyj/+Q2y/96f/N/2q6A94DBwAIBAcACGq6At7f/7n/7v/c/ev/1v/t/9n/7f/a/+3/2v/t/9r/7f/Z/+r+1f/y/+P/yPKW/5DbMf3s/9X/aroE3gMHAAgEBwAIaroC3uP/wf/z/+j98P/h//L/5P/z/+X/8//l//P/5f/y/+T/8P7g//j/7v/L8p3/kdsy/fD/3P9rugTeAwcACAQHAAhqugLe5v/J//j/8v31/+r/9v/t//f/7v/3/+//9//u//b/7f/0/un//f/4/87yo/+R2zL98f/f/2q5Bd0DBwAIBAcACGq6At7p/8///P/6/fj/8f/6//T/+v/1//r/9f/6//X/+v/0//f+8P//////0fGo/5PbNf30/+f/a7wE3AQJAAgEBwAIabkC3er/0f/+//79+v/0//v/9//8//j//P/4//z/+P/7//f/+f70///////T8qz/i9go+8P9ef9dqwCzAAACAAUJAAhquwHd7f7a//////z+//39/////f////3////9/////f////39/vz9/////dzzvv5v0AD1VqECqRUnAB8AAAAAAQACAGK0AL/J/Yf/8v7k/O3/1//u/9n/7v/Z/+7/2f/u/9n/7v/Z/+3/1//x/eP8vfxu/1WgAKYAAAUAAQIABAABAAAAAAAAHjcALmGzAMVquwLgarkC3Wq6At5qugLearoC3mq6At5qugLearkC3Wu8AeBbqgC3FScAHwAAAAACAwADAAAAAAAAAAAAAAAAAwQCAQQIAAgEBwAIBAcACAQHAAgEBwAIBAcACAQHAAgEBwAIBAgABwMDAgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
                    : "data:image/x-icon;base64,AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAyAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDAAQACAcEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAHCAMBBAEAAAAAAAAAAAAAAAACAAMDAAAAABUAJx9cAKq3awG84GoBud1qAbreagG63moBut5qAbreagG63mgAuN1qAbrgYgCzxR4ANy8AAAAAAAABAAEAAgQABAAAVwCgprNW/f/Wqf7805///9Si///Uov//1KL//9Si///Uov//16f//9Wl/vy3Yv3/YwC0vwEBAAAAAAAAFQAoH1cAoalyAM/1hh/Y/Ywn3P2KI9v9iyTb/Ysl2/2LJdv9iybb/Yki2v2bQ+L927X9/Neq/v9qAbvdBQAJCAABAABeAKuzr1H7/8WP9Pu+f/H/vn/y/76A8v++gPL/voDy/75/8v+9fvL/wof0/4wq3P+eS+L93rT//2gAud0DAAcIBQAJCGsBvNzVp/3/4sH//d+7///hv///4b///+G////hv///4b///9+7/v/nyf//w4rx/4wr2v3guv//agK63gMABwgEAAcIagK53dWl///gwP793rv+/9++/v/gv/7/4L/+/+C//v/fvv7/3br+/+TG///BhvH/jy3b/eTD//9qA7reAwAHCAQABwhqArre2rD//+jP//3lyv//583//+fO///nzv//587//+fN///lyP7/7Nb//8WP8v+QL9v96c3//2oDut4DAAcIBAAHCGoCut7fuf//7tz//evW///t2f//7dr//+3a///t2v//7dn//+rV/v/y4///yJby/5Ax2/3s1f//agS63gMABwgEAAcIagK63uPB///z6P/98OH///Lk///z5f//8+X///Pl///y5P//8OD+//ju///LnfL/kTLb/fDc//9rBLreAwAHCAQABwhqArre5sn///jy//316v//9u3///fu///37///9+7///bt///06f7//fj//86j8v+RMtv98d///2oFud0DAAcIBAAHCGoCut7pz////Pr//fjx///69P//+vX///r1///69f//+vT///fw/v//////0ajx/5M12/305///awS83AQACQgEAAcIaQK53erR///+/v/9+vT///v3///8+P///Pj///z4///79///+fT+///////TrPL/iyjY+8N5/f9dAKuzAAIAAAUACQhqAbvd7dr+//////z+/f/9/////f////3////9/////f////39/P79/////dy+8/5vAND1VgKhqRUAJx8AAAAAAQIAAGIAtL/Jh/3/8uT+/O3X///u2f//7tn//+7Z///u2f//7tn//+3X///x4/38vW78/1UAoKYABQAAAQACBAAAAQAAAAAAHgA3LmEAs8VqArvgagK53WoCut5qArreagK63moCut5qArreagK53WsBvOBbAKq3FQAnHwAAAAACAAMDAAAAAAAAAAAAAAAAAwIEAQQACAgEAAcIBAAHCAQABwgEAAcIBAAHCAQABwgEAAcIBAAIBwMCAwAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
            },
            click() {
                var newState = parent[PREF_ENABLED] = !parent[PREF_ENABLED];
                for(var btn of parent.btns) parent.setImg(btn, newState);
                newState ? parent.initChild() : parent.destroyChild();
                if (parent[PREF_RESET]) parent.setObserver(newState);
            },
            context(e) {
                if (e.ctrlKey || e.shiftKey) return;
                var btn = e.target;
                if (btn.btnPopup && e.detail > 1) return btn.btnPopup.hidePopup();
                e.preventDefault();
                (btn.btnPopup || parent.getPopup(btn)).openPopup(btn, "after_start");
            },
            getPopup(btn) {
                var win = btn.ownerGlobal, doc = win.document;
                var popup = doc.createElementNS(xulns, "menupopup");
                popup.setAttribute("onclick", "event.stopPropagation();");
                popup.setAttribute("oncommand", "handleCommand(event.target);");
                popup.setAttribute("onpopupshowing", "handlePopupshowing();");
                popup.menuitems = [];
                for(var [lab, pref] of win.Object.entries({
                    "Выделенный текст мигает при автокопировании": PREF_BLINK,
                    "Выключать автокопирование при выходе из браузера": PREF_RESET
                })) {
                    var menuitem = popup.appendChild(doc.createElementNS(xulns, "menuitem"));
                    menuitem.setAttribute("label", lab);
                    menuitem.setAttribute("type", "checkbox");
                    menuitem.pref = pref;
                    popup.menuitems.push(menuitem);
                }
                popup.handleCommand = menuitem => {
                    var newState = this[menuitem.pref] = menuitem.hasAttribute("checked");
                    if (!this[PREF_ENABLED]) return;

                    if (menuitem.pref == PREF_BLINK)
                        this.saveSettings(),
                        Services.ppmm.broadcastAsyncMessage(cid + ":FromParent", {blink: newState});
                    else if (menuitem.pref == PREF_RESET)
                        this.setObserver(newState);
                }
                popup.handlePopupshowing = () => {
                    for(var menuitem of popup.menuitems) this[menuitem.pref]
                        ? menuitem.setAttribute("checked", true)
                        : menuitem.removeAttribute("checked");
                }
                return btn.appendChild(btn.btnPopup = popup);
            },
            obsAdded: false,
            setObserver(set) {this.obsAdded = set
                ? Services.obs.addObserver(this, topic, false)
                : Services.obs.removeObserver(this, topic);
            },
            observe() {
                Services.obs.removeObserver(this, topic);
                this[PREF_ENABLED] = false;
                this.saveSettings();
            }
        }).init();
    }
    parent.register(this);
    addDestructor(reason => parent.unregister(this, reason), parent);

})(`(nsvo => (nsvo["%ID%"] = {
    x: -1, y: -1, down: false,
    handleEvent(e) {e.button || this[e.type](e);},
    mousedown(e) {this.x = e.screenX; this.y = e.screenY, this.down = true;},
    mouseup(e) {
        var {down} = this; this.down = false; if (!down) return;
        if (e.screenX == this.x && e.screenY == this.y && (e.detail == 1 || e.target.matches(
            "textarea[disabled],input[disabled],button,select,summary"
        )))
            return;
        var name = e.originalTarget.nodeName;
        if (/^(?:(?:xul:)?(?:slider|scrollbarbutton)|resizer)$/.test(name))
            return;
        this.x = this.y = -1;
        var win = this.getFocusedWin(e.target.ownerGlobal);
        var sel = win.getSelection();
        if (sel.toString()) {
            (win.docShell || win.document.docShell).doCommand("cmd_copy", null, win);
            this.blinkEnabled && this.blink(win, e.detail > 1);
        }
    },
    blinkEnabled: Boolean(
        Components.classes["@mozilla.org/preferences-service;1"]
            .getService(Components.interfaces.nsIPrefService)
            .getIntPref("%PREF%", 3) & %PREF_BLINK%
    ),
    blink(win, pause) {
        if (pause) return win.setTimeout(() => this.blink(win), 100);
        var sc = (win.docShell || win.document.docShell)
            .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
            .getInterface(Components.interfaces.nsISelectionDisplay)
            .QueryInterface(Components.interfaces.nsISelectionController);
        sc.setDisplaySelection(sc.SELECTION_OFF);
        sc.repaintSelection(sc.SELECTION_NORMAL);
        win.setTimeout(() => {
            sc.setDisplaySelection(sc.SELECTION_ON);
            sc.repaintSelection(sc.SELECTION_NORMAL);
        }, 150);
    },
    getFocusedWin(win) {
        var focusedWin = {};
        var elm = this.fm.getFocusedElementForWindow(win.top, true, focusedWin);
        return focusedWin.value;
    },
    get fm() {
        delete this.fm;
        return this.fm = Components.classes["@mozilla.org/focus-manager;1"]
            .getService(Components.interfaces.nsIFocusManager);
    },
    count: 0,
    init(cfmm) {
        this.count += 1;
        cfmm.addEventListener("mousedown", this);
        cfmm.addEventListener("mouseup", this);
        cfmm.addEventListener("unload", this);
        if (this.count == 1)
            this.cpmm.addMessageListener("%ID%:FromParent", this);
    },
    destroy(cfmm) {
        this.count -= 1;
        cfmm.removeEventListener("mousedown", this);
        cfmm.removeEventListener("mouseup", this);
        cfmm.removeEventListener("unload", this);
        if (!this.count)
            this.cpmm.removeMessageListener("%ID%:FromParent", this);
    },
    receiveMessage(msg) {
        if ("blink" in msg.data) this.blinkEnabled = msg.data.blink;
    },
    unload(e) {this.destroy(e.target);},
    forget: () => delete nsvo["%ID%"]

}).cpmm = this)(%NSVO%);`);


Добавлено 14-09-2019 13:57:27
Dumby
Еще одна просьба. Есть еще одна очень полезная кнопка: Перенести видео в плейер
скрытый текст

Выделить код

Код:

/*Initialization Code*/

var path = "c:\\INstaLL\\PotPlayer\\PotPlayerMini.exe";
var addToPlaylistKey = "/add";

var sysPlayerName = "POTPlayer";
var openIn = "Откыть в "+sysPlayerName;
var videoMoved = "Видео перенесено в "+sysPlayerName;
var noFound = "Не найдено видео на странице, доступное для переноса в "+sysPlayerName;

var Menu_n_TooltipTxts = [{
label: "Действие кнопки: Запустить видео сразу в "+sysPlayerName,
radio: '',
value: 'videotoplayer',
tooltipTxt: 'Запустить видео сразу в '+sysPlayerName
},
{
label: "Действие кнопки: Перенести видео в плейлист "+sysPlayerName,
radio: '',
value: 'videotoplaylist',
tooltipTxt: 'Перенести видео  в плейлист '+sysPlayerName
},
];

var YoutubeID = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\W|$)/;

if(!(cbu.getPrefs("CB.videoout.action")) || cbu.getPrefs("CB.videoout.action").length < 9) cbu.setPrefs("CB.videoout.action", "videotoplayer");
var tmp = '',
tmpp = '',
innerA = '<div style="display:block!important;color:#00ff00!important;width:250px!important;font:bold 16px serif!important;z-index:999!important;opacity:1!important;visibility: visible!important;',
innerB = 'left:5px!important;position:absolute!important;height:auto!important;box-sizing:border-box!important;padding:5px!important;margin:5px!important;',
stopPl = "javascript:(function(){v=document.getElementById('movie_player');if(v){v.stopVideo()}else{v=document.getElementsByTagName('video');if(v){v[0].src='';try{v[0].load()}catch(e){}};}})();",
ytIMGouter = function(ytID) {return '<div width="100%"><br /><a target="_blank" href="https://www.youtube.com/watch?v=' + ytID + '"><img src="https://i.ytimg.com/vi/' + ytID + '/hqdefault.jpg"></a><br />' + innerA + 'background-color:black!important;position:relative!important;bottom:20px!important;">&nbsp;&nbsp;' + videoMoved + '</div><br /></div><br />'},
handlWin = function(currentWin) {
tmp = '';
var elem = currentWin.document.getElementsByTagName('video'), currLoc = currentWin.location;
if(elem.length > 0) {
if(currLoc.hostname.indexOf('youtu') != -1 && (tmp = currLoc.toString().match(YoutubeID)) && tmp[1].length == 11) {
play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
videoMovedbox = currentWin.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>';
loadURI(stopPl);
currentWin.document.getElementById('eow-title').appendChild(videoMovedbox);
return true;
};
for(i = 0; i < elem.length; i++) {
if(((tmp = getSrc(elem[i].parentNode, currLoc)) && tmp.length > 2) || (i == 0 && currentWin.document.body.innerHTML.substring(0, 7) == '<video ' && (tmp = currLoc.toString()))) {
videoMovedbox = currentWin.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:20px!important;background-color:black!important;">' + videoMoved + '</div>';
play(tmp);                
if(currLoc.hostname == 'www.youtube.com') {
elem[i].parentNode.parentNode.appendChild(videoMovedbox);
} else {
elem[i].parentNode.appendChild(videoMovedbox);
};
elem[i].src = '';
try {
elem[i].load()
} catch(e) {};
return true;
}
}
};

currentWin._elems = currentWin.document.getElementsByTagName('iframe');
if(currentWin._elems.length > 0) {
for(currentWin._iCounter = 0; currentWin._iCounter < currentWin._elems.length; currentWin._iCounter++) {
if((currentWin._elems[currentWin._iCounter].src.indexOf('youtube.com') > -1) && (tmp = currentWin._elems[currentWin._iCounter].src.match(YoutubeID)) && (tmp[1].length == 11)) {
play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
currentWin._elems[currentWin._iCounter].outerHTML = ytIMGouter(tmp[1]);
return true;
};
if(currentWin._elems[currentWin._iCounter].clientWidth > 80 && currentWin._elems[currentWin._iCounter].clientHeight > 40 && handlWin(currentWin._elems[currentWin._iCounter].contentWindow))return true;
}
};

elem = currentWin.document.getElementsByTagName('object');
currLoc = currentWin.location;
if(elem.length == 0) {
elem = currentWin.document.getElementsByTagName('embed')
};
if(elem.length > 0) {
for(i = 0; i < elem.length; i++) {
if(elem[i].innerHTML.indexOf('youtu') != -1 && (tmp = elem[i].innerHTML.match(YoutubeID)) && tmp[1].length == 11) {
play(cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? 'https://www.youtube.com/embed/' + tmp[1] : 'https://www.youtube.com/watch?v=' + tmp[1]);
elem[i].outerHTML = ytIMGouter(tmp[1]);
return true;
} else {
if(elem[i].clientWidth > 80 && elem[i].clientHeight > 40) {
if(((tmp = getSrc(elem[i].parentNode, currLoc)) || (tmp = getLink(elem[i], currLoc))) && tmp.length > 2) {
play(tmp);
elem[i].outerHTML = innerA + 'background-color:black!important;bottom:20px!important;">&nbsp;&nbsp;' + videoMoved + '</div>';
return true;
};
};
}
};
};
return false;
};

this.onclick = this.oncontextmenu = e => {
if (e.target != this) return;
if(e.button == 0) {
if(cbu.getPrefs("CB.videoout.action").substring(0,6) == "videom"){
elem = content.document.getElementsByTagName('object');
if(elem.length == 0) {
elem = content.document.getElementsByTagName('embed')
};

resizeObjs(elem);
resizeObjs(content.document.getElementsByTagName('iframe'));
resizeObjs(content.document.getElementsByTagName('video'));
} else {
if(!handlWin(content))custombuttons.alertSlide1(noFound);
}
};

if(e.button == 1)
gShowPopup(self);

};
this.oncontextmenu = e => e.target != this ? menu.hasAttribute("context")
    : e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || (
        e.detail != 1 ? menu.hidePopup() : !!menu.openPopup(this, "after_start")
    );
custombuttons.alertSlide1 = function(sTitle) {
var as = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);
as.showAlertNotification('chrome://global/skin/icons/information-16.png', "", sTitle, false, "", null);
setTimeout(() => as.closeAlert(), 999);
};

function resizeObjs(objs) {
if(!objs) return;
LEVELS = 3;
dir = (cbu.getPrefs("CB.videoout.action") == "videomaximize") ? 1 : -1;
for(i = 0; i < objs.length; i++) {
var Width = new Array(LEVELS)
var Height = new Array(LEVELS)
Width[0] = objs[i].clientWidth;
Height[0] = objs[i].clientHeight;
if((Width[0] > (-20 * dir + 100)) && (Height[0] > (-20 * dir + 60))) {
obj = objs[i];
for(var k = 1;
((k < LEVELS) && (obj.parentNode)); k++) {
obj = obj.parentNode
Width[k] = obj.clientWidth;
Height[k] = obj.clientHeight;
};
Width[0] = Width[0] + dir * (Width[0] / 5 | 0);
Height[0] = Height[0] + dir * (Height[0] / 5 | 0);
objs[i].style.width = Width[0] + "px";
objs[i].width = Width[0];
objs[i].style.height = Height[0] + "px";
objs[i].height = Height[0];
obj = objs[i];
for(var k = 1;
((k < LEVELS) && !(objs[i].tagName == 'IFRAME') && (obj.parentNode) && (Width[k]) && (Height[k]) && (Width[k] > (-20 * dir + 100)) && (Height[k] > (-20 * dir + 60))); k++) {
obj = obj.parentNode
Width[k] = Width[k] + dir * (Width[k] / 5 | 0);
Height[k] = Height[k] + dir * (Height[k] / 5 | 0);
obj.style.width = Width[k] + "px";
obj.width = Width[k];
obj.style.height = Height[k] + "px";
obj.height = Height[k];
}
}
};
};

function restProtHost(lnkR, curLoc) {
if(lnkR.length==0)return '';
let tr = lnkR.replace(/^:\/\//, curLoc.protocol + "//");
if(!tr.match(/^https?:\/\//i)){
lnkR = tr.replace(/^\/+/, '');
if(lnkR.split('/')[0].split('?')[0].split('#')[0].toLowerCase().match(/^(?:[-a-z\d]+\.)+[a-z\d]{2,6}$/)){
tr = curLoc.protocol + '//' + lnkR;
}else{
tr = curLoc.protocol + '//' + curLoc.host + "/" + lnkR;
}
};
return tr;
};

function getSrc(vobj, currentLoc) {
var t = '',
tt = '';
if((((t = vobj.innerHTML.match(/<video.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i)) && (t) && (tt = t[1] || t[2] || t[3]) && tt.indexOf('blob:') == -1 ) || ((t = vobj.innerHTML.match(/<source.*?\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*)).*?\stype=['"]?video\//i)) && (t) && (tt = t[1] || t[2] || t[3]))) && tt.length > 2 && tt.indexOf('blob:') == -1 ) {
if(tt.indexOf(".mp4/?") == -1) {
tt = tt.replace(/&amp;/g, "&")
};
t = restProtHost(tt, currentLoc);
return t;
};
return '';
};

function getLink(obj, curLocation) {


if(!obj || !obj.tagName) return '';
var flashvars = '',
//        src = '',
q = obj.tagName.toLowerCase();

var getParam = function(e, n) {
var v = '',
r = new RegExp('^(' + n + ')$', 'i'),
param = e.getElementsByTagName('param');
for(var igp = 0, p; p = param[igp]; igp++) {
if(p.hasAttribute('name') && p.getAttribute('name').match(r)) {
v = p.getAttribute('value');
break
};
};
return v;
};


if(q == 'object') {
//        src = obj.getAttribute('data') || obj.getAttribute('src') || getParam(obj, 'movie|data|src|code|filename|url') || (obj.getElementsByTagName('embed').length > 0 ? obj.getElementsByTagName('embed')[0].getAttribute('src') : '');
flashvars = getParam(obj, 'flashvars');
} else if(q == 'embed') {
//        src = obj.getAttribute('src');
flashvars = obj.getAttribute('flashvars');
} else return '';


if(!flashvars) return '';
//   src = restProtHost(src, curLocation);

var restPath = function(f, s) {
return(f.substring(0, 4) == 'http') ? f : s.replace(/[#?].*$/, '').replace(/[^\/]*$/, f)
};

function videoLinkExtract(fl) {
//alert(fl);
var linkArr = [],
outLinks = [],
jj = 0,
lba = '',
lbb = '',
decodeURL = function(s) {
try {
return decodeURIComponent(s)
} catch(e) {
return unescape(s)
}
};

for(var ij = 0; ij < 3; ij++) {
lba = lba + String.fromCharCode(parseInt((Math.random() * 15 + 1) + '', 10));
lbb = lbb + String.fromCharCode(parseInt((Math.random() * 15 + 16) + '', 10));
};

function pushWithMerit(lnk) {

var merit = -11;
if(lnk.match(/^https?:\/\//i)) merit = merit + 40;
if(outLinks.length == 0) merit = merit + 1;
if(lnk.match(/^\//)) merit = merit + 7;
if(lnk.match(/^\/\//)) merit = merit + 30;
if(lnk.match(/240p([^a-z]|$)/i)) merit = merit + 1;
if(lnk.match(/[^a-z]240([^a-z0-9]|$)/i)) merit = merit + 1;
if(lnk.match(/360p([^a-z]|$)/i)) merit = merit + 3;
if(lnk.match(/[^a-z]360([^a-z0-9]|$)/i)) merit = merit + 3;
if(lnk.match(/480p([^a-z]|$)/i)) merit = merit + 5;
if(lnk.match(/[^a-z]480([^a-z0-9]|$)/i)) merit = merit + 5;
if(lnk.match(/720p([^a-z]|$)/i)) merit = merit + 7;
if(lnk.match(/[^a-z]720([^a-z0-9]|$)/i)) merit = merit + 7;
if(lnk.match(/\.mp4([^a-z]|$)/i)) merit = merit + 8;
if(lnk.match(/_hd([^a-z]|$)/i)) merit = merit + 6;
if(lnk.match(/\.(jpg|xml)([^a-z]|$)/i)) merit = merit - 40;
if(merit > 0) outLinks.push(merit + lba + lnk);
Services.console.logStringMessage('merit:'+merit+' lnk->'+lnk);
};

linkArr.push(fl);
while(linkArr.length > jj && jj < 30) {

var testPaths = [];
testPaths = linkArr[jj].split(/(\.(?:flv|mp4|m3u8))/i);
if(testPaths[testPaths.length - 1] == '') testPaths.pop();

for(k = 1; k < testPaths.length; k = k + 2) {

if(testPaths[k - 1].indexOf(lba) > -1) {
pref = testPaths[k - 1];
} else {
var testAboutDom = testPaths[k - 1].toLowerCase().split(/(https?:\/\/)/); 
if(testAboutDom[testAboutDom.length - 1]=='') testAboutDom.pop();
var pTest = testAboutDom[testAboutDom.length - 1].split(/(\?[^\?]*?&)/);
if(pTest.length>2){
pTest.pop();
pTest.pop();
};
testAboutDom[testAboutDom.length - 1] = pTest.join('');
pref = testPaths[k - 1].substring(testAboutDom.join('').lastIndexOf("&") + 1);
};

t2 = pref.lastIndexOf(lbb);
if(t2 > -1) {
pref = pref.substring(t2 + 3);
} else {

t2 = pref.lastIndexOf('{"');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.lastIndexOf('["');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.lastIndexOf(',"');
if(t2 > -1) pref = pref.substring(t2 + 2);
t2 = pref.toLowerCase().lastIndexOf('"http://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf('"https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(',http://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(',https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(';http');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf('*https://');
if(t2 > -1) pref = pref.substring(t2 + 1);
t2 = pref.toLowerCase().lastIndexOf(' or ');
if(t2 > -1) pref = pref.substring(t2 + 4);

pref = pref.substring(pref.split('/')[0].toLowerCase().split('%2f')[0].lastIndexOf('=') + 1);

}

if(pref.length > 0) {

if(pref.split('?')[0].toLowerCase().match(/%[2-3][0-9a-f]/)) {

t2 = pref.indexOf('"')
if(t2 > -1) pref = pref.substring(t2 + 1);
suff = testPaths[k + 1] ? testPaths[k + 1].split('&')[0].split('"')[0].split(';')[0].split(/,http/i)[0] : '';
if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) {
if(testPaths.length > k + 1) {
testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length)
};
t2 = pref.lastIndexOf(lba);
if(t2 > -1) pref = pref.substring(t2 + 3)
linkArr.push(decodeURL(pref + testPaths[k] + suff));

} else {
testPaths[k + 1] = (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff
}
} else {
suff = testPaths[k + 1] ? testPaths[k + 1].split(';')[0].split('"]')[0].split('"}')[0].split('",')[0].split(/,https?:\/\//i)[0].split('*https://')[0].split(' or ')[0] : '';
t2 = suff.indexOf('&');
if((t2 > -1) && (pref != testPaths[k - 1])) {
if(t2 == 0) suff = '';
if(suff.charAt(0) != '?') suff = suff.split(/(&[^&]+=https?:\/\/)/i)[0];
};
if((suff != testPaths[k + 1]) || (testPaths.length < k + 3)) {
if(testPaths.length > k + 1) {
testPaths[k + 1] = ((pref == testPaths[k - 1]) ? '' : '&') + testPaths[k + 1].substr(suff.length)
};
t2 = pref.lastIndexOf(lba);
if(t2 > -1) pref = pref.substring(t2 + 3);
pushWithMerit(pref + testPaths[k] + suff);

} else {
testPaths[k + 1] = lba + (pref == testPaths[k - 1] ? '' : lbb) + pref + testPaths[k] + suff
}
}
}
};
jj = jj + 1;
};

if(outLinks.length == 0) return '';
function srt(a, b) {
a = parseInt(a.substr(0, a.indexOf(lba)), 10);
b = parseInt(b.substr(0, b.indexOf(lba)), 10);
if(a < b) return 1;
if(a > b) return -1;
return 0
};
outLinks.sort(srt);
outLinks[0] = outLinks[0].substr(outLinks[0].indexOf(lba) + 3)
if(outLinks[0].indexOf('_hq.mp4/?time=') > 0) outLinks[0] = outLinks[0].replace(/&/g, '&amp;');
return outLinks[0];
};
ol = videoLinkExtract(flashvars);
if(!ol) return '';
//    ol = ol.replace(/^:?\/\//, curLocation.protocol + "//");
//    return restPath(ol, src);
return restProtHost(ol, curLocation);
};


var menu = self.appendChild(document.createElement("menupopup"));
self.image = "moz-icon://file://" + path;
var playerName = path.split("\\").pop().replace(".exe","");
self.label = "Открыть видео в " +sysPlayerName;
setTimeout(() => {
Menu_n_TooltipTxts.forEach((m) => {
if("separator" in m) {
menu.appendChild(document.createElement("menuseparator"));
return
};
var mItem = document.createElement("menuitem");
mItem.setAttribute("label", m.label);

if("radio" in m) {
mItem.setAttribute("type", "radio");
mItem.setAttribute('checked', cbu.getPrefs("CB.videoout.action") == m.value);
if(cbu.getPrefs("CB.videoout.action") == m.value) {
self.tooltipText = m.tooltipTxt;
}
mItem.onclick = () => {
cbu.setPrefs("CB.videoout.action", m.value);
tmp = (self.image == imgFlashToPlayer || self.image == imgFlashMinimize ||  self.image == imgFlashMaximize);
if(m.value.substring(0,9)=='videotopl'){
self.image = tmp ? imgFlashToPlayer : imgHTML5ToPlayer;
} else if(m.value=='videominimize') {
self.image = tmp ? imgFlashMinimize : imgHTML5Minimize;
} else self.image = tmp ? imgFlashMaximize : imgHTML5Maximize;
self.tooltipText = m.tooltipTxt;
};
}
if("checkbox" in m) {
mItem.setAttribute('type', 'checkbox');
mItem.setAttribute('checked', (self.image == imgFlashToPlayer || self.image == imgFlashMinimize ||  self.image == imgFlashMaximize ));
mItem.onclick = function(e) {
e.stopPropagation();
e.preventDefault();
if(e.button == 0) toggleFlash();
}
}
menu.appendChild(mItem);
});
menu.onclick = function(e) {
e.stopPropagation();
if(e.button > 0) e.preventDefault();
};
}, 100);
var contextMenu = document.getElementById("contentAreaContextMenu"); 
var menuitem = contextMenu.insertBefore(document.createElement("menuitem"), document.getElementById("context-sep-open"));
menuitem.setAttribute("label", "Открыть в " +sysPlayerName);      
menuitem.setAttribute("class", "menuitem-iconic");
menuitem.setAttribute("image", "moz-icon://file://" + path); 
menuitem.onclick = () => play(gContextMenu.linkURL);
addEventListener("popupshowing", ()=> menuitem.hidden = !gContextMenu.onLink, false, contextMenu);
addDestructor(()=> menuitem.remove() );
var contextMenu = document.getElementById("contentAreaContextMenu");
var mItem = contextMenu.insertBefore(document.createElement("menuitem"), document.getElementById("context-copyvideourl"));
mItem.setAttribute("label", openIn);
mItem.onclick = () => {
var vurl = gContextMenu.mediaURL, videoelem = gContextMenu.target;
if(videoelem && videoelem.nodeName.toLowerCase() == 'video') {
if(content.location.hostname.indexOf('youtu') != -1 && (tmp = content.location.toString().match(YoutubeID)) && tmp[1].length == 11) {
play(vurl);
videoMovedbox = content.document.createElement('videoMoved');
videoMovedbox.innerHTML = innerA + innerB + 'top:-15px!important;"><b>' + videoMoved + '</b></div>';
loadURI(stopPl);
content.document.getElementById('eow-title').appendChild(videoMovedbox);
return;
};

if(content.location.hostname == 'www.youtube.com') {
videoelem.parentNode.parentNode.appendChild(videoMovedbox);
} else {
var inFrameHref = inFrameWin.location.href, found = false;
if(inFrameWin.location.hostname == 'www.youtube.com' && (tmp = inFrameHref.match(YoutubeID)) && tmp[1].length == 11){//и значит во фрейме
elem = inFrameWin.parent.document.getElementsByTagName('iframe');
if(elem.length > 0) {
for(i = 0; i < elem.length; i++) {
if(elem[i].contentWindow == inFrameWin) {
elem[i].outerHTML = ytIMGouter(tmp[1]);
found = true;
break;
};
};
};
if(!found)inFrameWin.document.body.innerHTML = ytIMGouter(tmp[1]);
return;
};
videoelem.parentNode.appendChild(videoMovedbox);
};
videoelem.src = '';
try {
videoelem.load()
} catch(e) {};
} else play(vurl);
};


addEventListener("popupshowing", () => {
mItem.hidden = !gContextMenu.onVideo || !gContextMenu.mediaURL;
mItem2.hidden = !gContextMenu.linkURL;
mItem3.hidden = framItem.hidden || gContextMenu.target.ownerDocument.location.hostname.indexOf('youtube.com') == -1;
}, false, contextMenu);
addDestructor(() => {mItem.remove();mItem2.remove();mItem3.remove()});

function play(link) {
var file = Services.dirsvc.get('CurProcD', Ci.nsIFile);
var MozExeDir = file.path.split('\\').slice(0,-1).join('\\');
file.initWithPath(path);
if(!file.exists()) {
custombuttons.alertBox("File not found!", MozExeDir + Path);
return;
};
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);
process.run(false, [link, cbu.getPrefs("CB.videoout.action") == "videotoplaylist" ? addToPlaylistKey : ""], 2);
};


Не могли бы вы и ее исправить для многопроцессорного режима.

Отредактировано Garalf (14-09-2019 14:06:09)

Отсутствует

 

№1374214-09-2019 14:05:41

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 69.0

Re: Custom Buttons

Dumby
Тут уже тоже просят кнопку видео, присоединяюсь , пробую DecodeURI(gBrowser.currentURI) и прочее и никак...
Да, и кн. "переход на послед. вкладку " хотел на правый клик , а получается только на левый...

Отсутствует

 

№1374314-09-2019 14:07:20

xrun1
Участник
 
Группа: Members
Зарегистрирован: 12-12-2013
Сообщений: 573
UA: Firefox 68.0

Re: Custom Buttons

ifln
Я может чего не так понял и опоздал, пока ходил за картошкой в магазин.)) Dumby ответил...
user_pref("browser.ctrlTab.previews", true); // Для переключения между 2-мя рабочими вкладками при помощи быстрого CTRL+TAB по кругу
Я прашивал когда-то об этом
А кнопка в этом случае простая, в секцию /* CODE */

Выделить код

Код:

ctrlTab.open();
ctrlTab.pick();

Отсутствует

 

№1374414-09-2019 14:23:12

ifln
Участник
 
Группа: Members
Зарегистрирован: 20-09-2013
Сообщений: 209
UA: Firefox 60.0

Re: Custom Buttons

xrun1
Работает. Но CTRL+TAB я использую для переключения между всеми вкладками. А превью мне не нужно.

Отсутствует

 

№1374514-09-2019 18:30:17

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 69.0

Re: Custom Buttons

Andrey_Krropotkin
Простой google перевод под мульти. Не могуокно перевода задать. Тест -да, окно квадрат , ширину бы, как в старой кнопке.

Отсутствует

 

№1374614-09-2019 19:13:42

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 319
UA: unknown 0.0

Re: Custom Buttons

solombala в строчке 'var cnt" задаётся в стиле размеры окна width:240px;height:120px;
Потом в в строчках
cnt.style.height = 50*i+'px'; cnt.style.width = 100*i+'px';
Задаётся как будет расширяться окно при заполнении.
Я помоему вроде ничего не менял, посмотрите в старой кнопке эти параметры.

Отсутствует

 

№1374714-09-2019 20:32:32

solombala
Участник
 
Группа: Members
Зарегистрирован: 20-07-2019
Сообщений: 167
UA: Firefox 69.0

Re: Custom Buttons

Andrey_Krropotkin
Теперь другая лажа, выделить не могу? В старой отрихтованой без мульти - да.

Отсутствует

 

№1374814-09-2019 20:41:11

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 319
UA: unknown 0.0

Re: Custom Buttons

solombala да.

Отсутствует

 

№1374915-09-2019 05:18:03

xrun1
Участник
 
Группа: Members
Зарегистрирован: 12-12-2013
Сообщений: 573
UA: Firefox 68.0

Re: Custom Buttons

ifln пишет:

Работает. Но CTRL+TAB я использую для переключения между всеми вкладками. А превью мне не нужно.

Настройка browser.ctrlTab.previews теперь действительно бессмысленна, но Ctrl+Tab переключает между 2-мя последними вкладками, если не обращать внимание на выскакивающее превью. Это в том случае, если browser.ctrlTab.recentlyUsedOrder;true. Хотя сам я пользуюсь для этого жестом.

Отсутствует

 

№1375015-09-2019 22:54:25

Stkvsky
Участник
 
Группа: Members
Зарегистрирован: 26-06-2012
Сообщений: 1291
UA: Firefox 56.0

Re: Custom Buttons

Dumby здравствуйте, можно вас попросить, если вас не затруднит, вы бы не могли пожалуйста, сделать такую кнопку,
Чтобы при удалении вкладки из закладок, автоматически загружалась следующая закладка из той же папки где была эта которую удалил?

Отредактировано Stkvsky (16-09-2019 00:44:01)

Отсутствует

 

Board footer

Powered by PunBB
Modified by Mozilla Russia
Copyright © 2004–2011 Mozilla Russia
Язык отображения форума: [Русский] [English]