человек сделал javascript, который реализовал поиск по форуму через google именно такой функцией.
Для FF тоже такое есть - Search in Website+
Хотя, наверное, возможность, при зажатом Ctrl или чего-то такого, производить поиск по сайту в выбранной поисковой системе, была бы интересной, правда не знаю поддерживают ли всякие дакдаки и яндексы такую фичу...
Отсутствует
Можешь добавить в текст пункта меню выделенное/искомое слово?
// 2013-09-22 (function () { function _localize(sid) { let strings = { en : { siteSearch : "Site Search" }, ru : { siteSearch : "Поиск по сайту" } }; let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } var searchSelect = document.getElementById('context-searchselect'); searchSelect.collapsed = true; var contextMenu = document.getElementById("contentAreaContextMenu"); var menu = contextMenu.insertBefore(document.createElement('menu'), searchSelect); menu.setAttribute("class", "menu-iconic"); var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var engines = searchService.getVisibleEngines({}); var isCustomEngine = false; var customName = "Google"; if (customName != "") { for (let i in engines) { if (engines[i].name != customName) continue; menu.setAttribute("label", engines[i].name); menu.style.listStyleImage = 'url("' + engines[i].iconURI.spec + '")'; menu.mEngine = engines[i]; isCustomEngine = true; break; } } if (!isCustomEngine) { menu.setAttribute("label", searchService.defaultEngine.name); menu.style.listStyleImage = 'url("' + searchService.defaultEngine.iconURI.spec + '")'; menu.mEngine = searchService.defaultEngine; } menu.setAttribute("onclick", "\ if (!event.target.mEngine) return;\ var submission = event.target.mEngine.getSubmission( getBrowserSelection(), null );\ gBrowser.loadOneTab( submission.uri.spec, {relatedToCurrent: true, postData: submission.postData, inBackground: false} );\ setTimeout(function() { document.getElementById('contentAreaContextMenu').hidePopup() }, 0);\ "); var observeStatus = new MutationObserver(function () { menu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); addDestructor(function () { contextMenu.removeChild(menu); observeStatus.disconnect(); searchSelect.collapsed = false; }); var menuPopup = menu.appendChild(document.createElement("menupopup")); addEventListener('popupshowing', function (e) { if (e.target != contextMenu) return; var selectedText = getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (e) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; var engineName = isCustomEngine ? customName : searchService.defaultEngine.name; var menuLabel = engineName; try { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearch", [engineName, selectedText]); } catch (e) { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearchText", [engineName, selectedText]); } menu.label = menuLabel; function clearMenuLabel(e) { if (e.target != contextMenu) return; removeEventListener(e.type, clearMenuLabel, false, contextMenu); menu.label = engineName; } addEventListener('popuphiding', clearMenuLabel, false, contextMenu); }, false, contextMenu); var siteSearchGoogle; for (let i in engines) { if (engines[i].name != "Google") continue; siteSearchGoogle = engines[i]; break; } addEventListener('popupshowing', function (e) { menuPopup.textContent = ""; function mItemCreate(trg, ssg/*, dm*/) { var mItem = document.createElement("menuitem"); mItem.setAttribute("class", "menuitem-iconic"); mItem.engine = trg; if (ssg == "siteSearchGoogle") { menuPopup.appendChild(document.createElement("menuseparator")); mItem.setAttribute("label", _localize("siteSearch") /*+ ": " + dm*/); //mItem.setAttribute("src", gBrowser.selectedTab.image); mItem.setAttribute(ssg, "true"); } else { mItem.setAttribute("label", trg.name); mItem.setAttribute("src", trg.iconURI.spec); } menuPopup.appendChild(mItem); } for (let i in engines) { if (isCustomEngine && engines[i].name == customName || !isCustomEngine && engines[i].name == searchService.defaultEngine.name) continue; mItemCreate(engines[i]); } function isDomain() { var domain; try { domain = gBrowser.currentURI.host; } catch (e) {} return domain; } if (siteSearchGoogle && isDomain()) { mItemCreate(siteSearchGoogle, "siteSearchGoogle"/*, isDomain()*/); } menuPopup.setAttribute("oncommand", "\ if (!event.target.engine) return;\ var ssg = '';\ if (event.target.hasAttribute('siteSearchGoogle')) {\ ssg = ' site:' + gBrowser.currentURI.host;\ }\ var submission = event.target.engine.getSubmission(getBrowserSelection() + ssg, null);\ gBrowser.loadOneTab( submission.uri.spec, {relatedToCurrent: true, postData: submission.postData, inBackground: false} );\ "); }, false, menu); })();
Отредактировано 2k1dmg (22-09-2013 19:42:14)
Отсутствует
dedmazai1870, в основной версии Context Search так и сделано, там стоит - в пункт меню выводится не более 16 символов из выделенного текста.
Добавлено 21-09-2013 23:10:33
2k1dmg, вот теперь именно то, что я хотел.
Отредактировано PEAKTOP (22-09-2013 19:38:59)
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует
Zaycoff
А вот объединить 2 кнопки как? Чтобы с списку моих поисков добавлялся гуглопоиск последней строкой "Включает строку поиска выделенного текста на текущем сайте". Вот чего хочется.
Отсутствует
Отсутствует
Добавил "Поиск по текущему сайту" через Яндекс
//Context Search - искать поисковыми системами через контекстное меню............................... (function () { function _localize(sid) { let strings = { en : { siteSearch : "Search this site - Google" }, ru : { siteSearch : "Поиск по этому сайту - Google" } }; let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } function _localize2(sid) { let strings = { en : { siteSearch2 : "Search this site - Yandex" }, ru : { siteSearch2: "Поиск по этому сайту - Яндекс" } }; let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; _localize2 = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize2.apply(this, arguments); } var searchSelect = document.getElementById('context-searchselect'); searchSelect.collapsed = true; var contextMenu = document.getElementById("contentAreaContextMenu"); var menu = contextMenu.insertBefore(document.createElement('menu'), searchSelect ); menu.setAttribute("class", "menu-iconic"); var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var engines = searchService.getVisibleEngines({}); var isCustomEngine = false; var customName = "Google"; if (customName != "") { for (let i in engines) { if (engines[i].name != customName) continue; menu.setAttribute("label", engines[i].name); menu.style.listStyleImage = 'url("' + engines[i].iconURI.spec + '")'; menu.mEngine = engines[i]; isCustomEngine = true; break; } } if (!isCustomEngine) { menu.setAttribute("label", searchService.defaultEngine.name); menu.style.listStyleImage = 'url("' + searchService.defaultEngine.iconURI.spec + '")'; menu.mEngine = searchService.defaultEngine; } menu.setAttribute("onclick", "\ if ( !!event.target.engine || !event.target.mEngine) return;\ var submission = event.target.mEngine.getSubmission( getBrowserSelection(), null );\ gBrowser.loadOneTab( submission.uri.spec, {relatedToCurrent: true, postData: submission.postData, inBackground: false} );\ setTimeout(function() { document.getElementById('contentAreaContextMenu').hidePopup() }, 0);\ "); var observeStatus = new MutationObserver(function () { menu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); addDestructor(function () { contextMenu.removeChild(menu); observeStatus.disconnect(); searchSelect.collapsed = false; }); var menuPopup = menu.appendChild(document.createElement("menupopup")); addEventListener('popupshowing', function (e) { if (e.target != contextMenu) return; var selectedText = getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (e) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; var engineName = isCustomEngine ? customName : searchService.defaultEngine.name; var menuLabel = engineName; try { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearch", [engineName, selectedText]); } catch (e) { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearchText", [engineName, selectedText]); } menu.label = menuLabel; function clearMenuLabel(e) { if (e.target != contextMenu) return; removeEventListener(e.type, clearMenuLabel, false, contextMenu); menu.label = engineName; } addEventListener('popuphiding', clearMenuLabel, false, contextMenu); }, false, contextMenu); addEventListener('popupshowing', function (e) { menuPopup.textContent = ""; for (let i in engines) { if (isCustomEngine && engines[i].name == customName || !isCustomEngine && engines[i].name == searchService.defaultEngine.name) continue; var mItem = document.createElement("menuitem"); mItem.setAttribute("label", engines[i].name); mItem.setAttribute("class", "menuitem-iconic"); mItem.setAttribute("src", engines[i].iconURI.spec); mItem.engine = engines[i]; menuPopup.appendChild(mItem); } menuPopup.setAttribute("oncommand", "\ if ( !event.target.engine ) return;\ var submission = event.target.engine.getSubmission( getBrowserSelection(), null );\ gBrowser.loadOneTab( submission.uri.spec, {relatedToCurrent: true, postData: submission.postData, inBackground: false} );\ "); menuPopup.appendChild(document.createElement("menuseparator")); var mItemSbS = menuPopup.appendChild(document.createElement("menuitem")); mItemSbS.setAttribute("class", "menuitem-iconic"); mItemSbS.setAttribute("image", "data:image/x-icon;base64,AAABAAEAEhIAAAEAIACABQAAFgAAACgAAAASAAAAJAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBKBMpTCYX4GMrH/9gMxn/YDQV/2cyG/9nLxr/YjMd/10xHv9cMRz/XjIa/2ExHP9gNRn/YDIV/2IwHf9ULSL/RCcU4EEoEylLKBfgcjUe/349IP98QRr/gEEd/39AKP+FUjv/h2NL/4lkUP+GYEv/hVQ+/35CJv9+Phz/gEIb/4c8H/96PCT/azgb/0koFOBpMyT/jD8i/4RFIf97RB3/hEUr/7GCdf/q29L/+e3e/97HuP/dwLD/6M2+/76VhP9+RSr/hUMg/5NAH/+NQCX/h0Ai/2Q1Iv9yOyf/lkYn/4xFJP+HSSn/m25Y//7y6v/bw7f/fkw2/3hBJv90QSX/hFI9/+nUxv+2k4H/i0kq/5VIJP+QRiL/lkYn/3Q5Kv9zQSn/mUkp/5tJKf+XSin/roJr//757f+0gG//l0oq/5NMI/+WTCH/i00u/8q0o//jx7j/mFU6/5JMJP+TTiL/l0wl/3Y/K/93Rif/oE4p/6ZNK/+jTSz/pGpS//rn2v/Np5b/kFEx/5BSK/+XTyv/nmFJ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O/+5+Tv/uhVj/3YFa/5JYPOCRVkEppFo64NN8UP/dgVT/3oRR/92DTP/ihVj/34FX/+ODVf/mg1T/5IRO/96ET//cglH/4YJT/+CCVv/Te1D/oVk44JBVQCkAAABBAAAAQQAAAEEAAABBAAAAQQAAAEEAAABBAAAAQQAAAEEAAABBAAAAQQAAAEEAAABBAAAAQQAAAEEAAABBAAAAQQAAAEE=") mItemSbS.setAttribute("label", _localize("siteSearch")); mItemSbS.setAttribute("oncommand", "\ var selectedText = getBrowserSelection(); if (!selectedText) return;\ try {var domain = content.document.domain;} catch (e) {return;}\ selectedText = encodeURIComponent(selectedText);\ gBrowser.loadOneTab( 'https://www.google.com/search?q=' + selectedText + '&filter=0&as_q=site:' + domain, {relatedToCurrent: true, inBackground: false} );\ "); //menuPopup.appendChild(document.createElement("menuseparator")); var mItemSbS = menuPopup.appendChild(document.createElement("menuitem")); mItemSbS.setAttribute("class", "menuitem-iconic"); mItemSbS.setAttribute("image", "data:application/file;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABCklEQVR4nKVTuwrCUAw9vXRwEnF0kI4iTuLg5NRB/BRx6IeIk4M4iJ/SoWM/QMTByUnED5ATh+AjrdqqgXC5JDn3JOfGIyn4wpxznrnnMuZzYDgEwhAIAsD3gSi6h3MPkpS7z2bCRkN4Oul9NBJWq2JyMgCWwWIB9HpArfaxjWcQC3A+A5XKx+KsWYBWC9jvSxXeWFiAKALSFJhOgculHIXsgLhaCZ0TttvCZvPlEJ89L+N6ra0kCdDpFBKwAEmiPpkUKgHop7IAcaxnGBYWv2aQpipjEJR6PQ+w2Wj/vv8Dg+MR2O2Afv8RfSOlWSiSwsNBOBgI63XhdqsSLZfCbld9PH67C96/63wFqBHGA4wLrxUAAAAASUVORK5CYII=") mItemSbS.setAttribute("label", _localize2("siteSearch2")); mItemSbS.setAttribute("oncommand", "\ var selectedText = getBrowserSelection(); if (!selectedText) return;\ try {var domain = content.document.domain;} catch (e) {return;}\ selectedText = encodeURIComponent(selectedText);\ gBrowser.loadOneTab( 'http://yandex.ru/yandsearch?text=' + selectedText + '&site=' + domain, {relatedToCurrent: true, inBackground: false} );\ "); }, false, menu); })(); // Библиотека - Открывать библиотеку в вкладке и последнюю активную папку библиотеки, от 08.09.2013. ................................ (function () { var command; const pn = "CB.lastUsedLibraryFolder"; const library = "chrome://browser/content/places/places.xul"; // Перехватывать открытие библиотеки и открывать её в вкладке рядом с текущей .... function libraryInTab(e) { var oncommand = e.target.getAttribute("oncommand"); if ( !/PlacesCommandHook.showPlacesOrganizer|DownloadsUI|DownloadsPanel/.test( oncommand ) ) return; if ( /UnfiledBookmarks/.test( oncommand ) && e.type == 'click' ) return; e.stopPropagation(); command = oncommand; setTimeout(function() { document.getElementById("appmenu-popup").hidePopup() }, 0); // закрыть все вкладки библиотеки кроме первой .... var libTab = null; Array.slice( gBrowser.tabs ).forEach(function(tab) { if ( tab.linkedBrowser.currentURI.spec !== library ) return; !libTab ? libTab = tab : gBrowser.removeTab(tab); }) // переместить или открыть библиотеку рядом с текущей вкладкой .... var selTab = gBrowser.selectedTab; if ( libTab !== selTab ) { if ( libTab && gBrowser.visibleTabs.indexOf(libTab) == -1 ) TabView.moveTabTo( libTab, TabView._window.GroupItems._activeGroupItem.id ); libTab = libTab || gBrowser.addTab( library ); var pos = selTab._tPos + ( libTab._tPos > selTab._tPos ); gBrowser.moveTabTo( libTab, pos ); gBrowser.selectedTab = libTab; // если библиотека уже открыта if ( !libTab.hasAttribute('busy') ) openLastUsedFolder( false, content.document.defaultView ); } }; addEventListener("command", libraryInTab, true, window ); addEventListener("click", libraryInTab, true, document.getElementById('appmenuSecondaryPane') ); // Открывать и запоминать последнюю активную папку если библиотека открыта как вкладка .... function openLastUsedFolder( e, win ) { if ( e !== false ) { var win = e.target.defaultView; if ( win.location != library ) return; } // получить нужную папку try { var value = cbu.getPrefs( pn ) } catch(e) { var value = '' }; if ( /History/.test( command ) ) value = 'place:sort=4&type=3'; if ( /UnfiledBookmarks/.test( command ) ) value = 'place:folder=UNFILED_BOOKMARKS&excludeItems=1&expandQueries=0'; if ( /DownloadsUI|DownloadsPanel/.test( command ) ) value = 'place:transition=7&sort=4'; if ( /DownloadsPanel/.test( command ) ) setTimeout(function() { document.getElementById("downloadsPanel").hidePopup() }, 10); // открыть нужную папку используя рекурсию (function f() { try { win.PlacesOrganizer.location = value; win.PlacesOrganizer._places.focus(); } catch(e) { setTimeout(function() { f() }, 0) }; })(); // запоминать последнюю папку при закрытии библиотеки if ( e == false ) return; win.addEventListener("unload", function(e) { this.removeEventListener( e.type, arguments.callee, false ); var loc = win.PlacesOrganizer.location; if ( loc == 'place:transition=7&sort=4') return; // исключить папки загрузки if ( /place:beginTime|place:sort=4&type=3/.test( loc ) ) return; // исключить папки истории cbu.setPrefs( pn, loc ); }, false ); }; addEventListener("DOMContentLoaded", openLastUsedFolder, false, gBrowser ); })();
Отредактировано PEAKTOP (24-09-2013 19:40:26)
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует
Context Search 2013-09-23
// 2013-09-23 (function () { var options = { customName: "Google", // оставить пустым если не нужно закреплять // определенный поисковик // примеры customName: "Google" или customName: "Яндекс" или customName: "" hideDefaultEngineInList: false, // true - не допбовлять поисковик по умолчанию в выпадающий список поисковиков siteSearchIconsOn: true // true - добавить иконки для поисковиков по сайту }; function _localize(sid) { let strings = { en: { siteSearchGoogle: "Search this site - Google", siteSearchYandex: "Search this site - Yandex", siteSearchYahoo: "Search this site - Yahoo", siteSearchBing: "Search this site - Bing", siteSearchDuckDuckGo: "Search this site - DuckDuckGo" }, ru: { siteSearchGoogle: "Поиск по этому сайту - Google", siteSearchYandex: "Поиск по этому сайту - Яндекс", siteSearchYahoo: "Поиск по этому сайту - Yahoo", siteSearchBing: "Поиск по этому сайту - Bing", siteSearchDuckDuckGo: "Поиск по этому сайту - DuckDuckGo" } }; let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } var contextSearcherObj = { commandHandler: function (event, trg) { var inBg = false; if (event.type == "click" && event.button && event.button == 1) { inBg = true; } var siteSearch = ''; if (event.target.hasAttribute('siteSearch')) { siteSearch = ' site:' + gBrowser.currentURI.host; } var submission = event.target.engine.getSubmission(getBrowserSelection() + siteSearch, null); gBrowser.loadOneTab(submission.uri.spec, { relatedToCurrent: true, postData: submission.postData, inBackground: inBg }); if (trg == "menu") { setTimeout(function () { document.getElementById('contentAreaContextMenu').hidePopup(); }, 0); } } } var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var engines = searchService.getVisibleEngines({}); var contextMenu = document.getElementById("contentAreaContextMenu"); var searchSelect = document.getElementById('context-searchselect'); searchSelect.style.display = 'none'; var menu = contextMenu.insertBefore(document.createElement('menu'), searchSelect); menu.setAttribute("id", "Context_Search_mini_By_bunda1"); menu.setAttribute("class", "menu-iconic"); var isCustomEngine = false; var customName = options.customName; if (customName != "") { for (let i in engines) { if (engines[i].name != customName) continue; menu.setAttribute("label", engines[i].name); menu.style.listStyleImage = 'url("' + engines[i].iconURI.spec + '")'; menu.engine = engines[i]; isCustomEngine = true; break; } } if (!isCustomEngine) { menu.setAttribute("label", searchService.defaultEngine.name); menu.style.listStyleImage = 'url("' + searchService.defaultEngine.iconURI.spec + '")'; menu.engine = searchService.defaultEngine; } menu.searchWith = contextSearcherObj.commandHandler; menu.setAttribute("onclick", "if (event.target == this && event.target.engine) this.searchWith(event, 'menu');"); addEventListener('popupshowing', function (e) { if (e.target != contextMenu) return; var selectedText = getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (e) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; var engineName = isCustomEngine ? customName : searchService.defaultEngine.name; var menuLabel = engineName; try { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearch", [engineName, selectedText]); } catch (e) { menuLabel = gNavigatorBundle.getFormattedString("contextMenuSearchText", [engineName, selectedText]); } menu.label = menuLabel; function clearMenuLabel(e) { if (e.target != contextMenu) return; removeEventListener(e.type, clearMenuLabel, false, contextMenu); menu.label = engineName; } addEventListener('popuphiding', clearMenuLabel, false, contextMenu); }, false, contextMenu); var menuPopup = menu.appendChild(document.createElement("menupopup")); //menuPopup.textContent = ""; var mSeparator; function mItemCreate(trg, ssl) { var mItem = document.createElement("menuitem"); mItem.setAttribute("class", "menuitem-iconic"); mItem.engine = trg; if (ssl) { if (!mSeparator ) { mSeparator = document.createElement("menuseparator"); mSeparator.setAttribute("siteSearch", "true"); menuPopup.appendChild(mSeparator); } mItem.setAttribute("label", _localize(ssl)); if (options.siteSearchIconsOn) { mItem.setAttribute("src", trg.iconURI.spec); } mItem.setAttribute("siteSearch", "true"); } else { mItem.setAttribute("label", trg.name); mItem.setAttribute("src", trg.iconURI.spec); } menuPopup.appendChild(mItem); } for (let i in engines) { if (options.hideDefaultEngineInList && isCustomEngine && engines[i].name == customName || options.hideDefaultEngineInList && !isCustomEngine && engines[i].name == searchService.defaultEngine.name) { LOG(engines[i].name); continue; } mItemCreate(engines[i]); } var siteSearchArr = []; [ ["Google", ["Google"]], ["Yandex", ["Yandex", "Яндекс"]], ["Yahoo", ["Yahoo"]], ["Bing", ["Bing"]], ["DuckDuckGo", ["DuckDuckGo"]] ].forEach(function(elem) { for (let i in engines) { if (elem[1].indexOf(engines[i].name) == -1) continue; siteSearchArr.push([elem[0], engines[i]]); break; } }); if (siteSearchArr[0]) { siteSearchArr.forEach(function(elem) { mItemCreate(elem[1], "siteSearch" + elem[0]); }); } menuPopup.searchWith = contextSearcherObj.commandHandler; menuPopup.setAttribute("oncommand", "if (!event.target.engine) return; this.searchWith(event);"); menuPopup.setAttribute("onclick", "checkForMiddleClick(this, event);"); addEventListener('popupshowing', function (e) { var siteSearchDomain; function isDomain() { try { siteSearchDomain = gBrowser.currentURI.host; } catch (e) { return false; } return true; } var mItems; if (!menuPopup.mItems) { var mItemsObg = menuPopup.getElementsByTagName("menuitem"); menuPopup.mItems = []; Array.slice(mItemsObg).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.hasAttribute("siteSearch")) menuPopup.mItems.push(elem); }); mItems = menuPopup.mItems; } else { mItems = menuPopup.mItems; } if (isDomain()) { mItems.forEach(function(elem) { elem.removeAttribute("disabled"); elem.setAttribute("tooltiptext", siteSearchDomain); }); } else { mItems.forEach(function(elem) { elem.setAttribute("disabled", "true"); elem.removeAttribute("tooltiptext"); }); } }, false, menu); var observeStatus = new MutationObserver(function () { menu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); addDestructor(function () { contextMenu.removeChild(menu); observeStatus.disconnect(); document.getElementById('context-searchselect').style.removeProperty('display'); }); })();
Отсутствует
Context Search 2013-09-23
А зачем ты изменяешь меню при закрытии :
function clearMenuLabel(e) { if (e.target != contextMenu) return; removeEventListener(e.type, clearMenuLabel, false, contextMenu); menu.label = engineName; } addEventListener('popuphiding', clearMenuLabel, false, contextMenu);
если потом пункт меню при открытии меню опять меняется:
addEventListener('popupshowing', function (e) { .................... menu.label = menuLabel;
Отредактировано bunda1 (23-09-2013 22:10:44)
Отсутствует
2k1dmg, есть одно неудобство. Если я зафиксирую в пункте меню "Google", то он будет дублироваться и в подменю. Понятно, что ты берешь список поисковиков из "Панели поиска". Есть возможность исключить "зафиксированный" поисковик из подменю?
Отредактировано PEAKTOP (25-09-2013 00:40:20)
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует
PEAKTOP
Там же есть options (с описанием настроек), где можно изменить:
hideDefaultEngineInList: true
bunda1
Убрал изменение меню при закрытии и
добавил "Поиск по изображени"
// 2013-09-25 (function () { var options = { pinnedEngineName: "", // оставить пустым если не нужно закреплять // определенный поисковик // примеры pinnedEngineName: "Google" или pinnedEngineName: "Яндекс" или pinnedEngineName: "" hideDefaultEngineInList: false, // true - не добавлять поисковик по умолчанию в выпадающий список (подменю) поисковиков siteSearch: { enable: true, // true - добавить поисковики по сайту iconsOn: true, // true - добавить иконки для поисковиков по сайту useDefaultNamesList: true, // true - использовать список поисковиков по умолчанию addCustomNames: false, // true - добавить свои поисковики по сайту customNamesList: [ ["Rambler", ["Rambler", "Рамблер"]] ] // например ["Rambler", ["Rambler", "Рамблер"]] // первая ячека название на английском // вторая ячека массив с предполагаемыми именами поисковика // может состоять из нескольких значений // ["Name1", ["Name1"]], // ["Name2", ["Name2", "Имя2"]], // ["Name3", ["Name3", "Имя3", "Név3"]] }, addImageSearch: true // true - добавить поиск изображений }; function _localize(sid) { let strings = { en: { siteSearch: "Search this site", searchImage: "Search by image" }, ru: { siteSearch: "Поиск по этому сайту", searchImage: "Поиск по изображению" } }; let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } var contextSearcherObj = { init: function() { var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var contextMenu = document.getElementById("contentAreaContextMenu"); var searchSelect = document.getElementById("context-searchselect"); searchSelect.style.display = "none"; var menu = contextMenu.insertBefore(document.createElement("menu"), searchSelect); this.searchService = searchService; this.contextMenu = contextMenu; this.menu = menu; var observeStatus = new MutationObserver(function () { menu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); this.branch = prefService.getBranch("browser.search."); if (!("addObserver" in this.branch)) this.branch.QueryInterface(Components.interfaces.nsIPrefBranch2); this.branch.addObserver("", this, false); Services.ww.registerNotification(this); this.createMenu(); if (options.addImageSearch) this.creatImageMenu(); addDestructor(function () { observeStatus.disconnect(); searchSelect.style.removeProperty("display"); Services.ww.unregisterNotification(this); this.branch.removeObserver("", this); this.destroy(); }, this); }, destroy: function() { var contextMenu = this.contextMenu; var menu = this.menu; if (menu) contextMenu.removeChild(menu); var imageMenu = this.imageMenu; if (imageMenu) contextMenu.removeChild(imageMenu); }, update: function() { this.menu.textContent = ""; this.createMenu(); }, observe: function(subject, topic, data) { switch (topic) { case "domwindowclosed": if (subject.document.documentElement.getAttribute("windowtype") == "Browser:SearchManager") { this.update(); } break; case "nsPref:changed": if (data == "defaultenginename") this.update(); break; } }, handleEvent: function(e) { var contextMenu = this.contextMenu; var menu = this.menu; var imageMenu = this.imageMenu; switch (e.type) { case "popupshowing": if(e.target == contextMenu) { this.contextMenuPopup(e); if (imageMenu) this.imageMenuPopup(e); } else if (e.target == menu) this.contextSearcherMenuPopup(e); break; } }, commandHandler: function(event, trg) { var inBg = false; if (event.type == "click" && event.button && event.button == 1) { inBg = true; } var siteSearch = ""; if (event.target.hasAttribute("siteSearch")) { siteSearch = " site:" + gBrowser.currentURI.host; } var submission = event.target.engine.getSubmission(getBrowserSelection() + siteSearch, null); gBrowser.loadOneTab(submission.uri.spec, { relatedToCurrent: true, postData: submission.postData, inBackground: inBg }); if (trg == "menu") { setTimeout(function () { document.getElementById("contentAreaContextMenu").hidePopup(); }, 0); } }, contextMenuPopup: function(e) { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.menu; var selectedText = getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (e) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; var engineName = this.isCustomEngine ? customName : searchService.defaultEngine.name; var menuLabel; var searchFormattedString = [ "contextMenuSearch", "contextMenuSearchText" ]; function getMenuLabel(str) { try { return gNavigatorBundle.getFormattedString(str, [engineName, selectedText]); } catch (e) {} } for(let i in searchFormattedString) { menuLabel = getMenuLabel(searchFormattedString[i]); if (menuLabel) break; else if (!menuLabel && i == searchFormattedString.length-1) menuLabel = engineName; } menu.label = menuLabel; }, contextSearcherMenuPopup: function(e) { var siteSearchDomain; function isDomain() { try { siteSearchDomain = gBrowser.currentURI.host; } catch (e) { return false; } return true; } var mItems; if (!menuPopup.mItems) { var mItemsObg = menuPopup.getElementsByTagName("menuitem"); menuPopup.mItems = []; Array.slice(mItemsObg).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.hasAttribute("siteSearch")) menuPopup.mItems.push(elem); }); mItems = menuPopup.mItems; } else { mItems = menuPopup.mItems; } if (isDomain()) { mItems.forEach(function(elem) { elem.removeAttribute("disabled"); elem.setAttribute("tooltiptext", siteSearchDomain); }); } else { mItems.forEach(function(elem) { elem.setAttribute("disabled", "true"); elem.removeAttribute("tooltiptext"); }); } }, createMenu: function() { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.menu; var engines = searchService.getVisibleEngines({}); menu.setAttribute("id", "Context_Search_mini_By_bunda1"); menu.setAttribute("class", "menu-iconic"); this.isCustomEngine = false; var customName = options.pinnedEngineName; if (customName != "") { for (let i in engines) { if (engines[i].name != customName) continue; menu.setAttribute("label", engines[i].name); menu.setAttribute("image", engines[i].iconURI.spec); menu.engine = engines[i]; this.isCustomEngine = true; break; } } if (!this.isCustomEngine) { menu.setAttribute("label", searchService.defaultEngine.name); menu.setAttribute("image", searchService.defaultEngine.iconURI.spec); menu.engine = searchService.defaultEngine; } menu.gObj = this; menu.setAttribute("onclick", "if (event.target == this && event.target.engine) this.gObj.commandHandler(event, 'menu');"); addEventListener("popupshowing", this, false, contextMenu); var menuPopup = menu.appendChild(document.createElement("menupopup")); var mSeparator; function mItemCreate(engine, siteSearch) { var mItem = document.createElement("menuitem"); mItem.setAttribute("class", "menuitem-iconic"); mItem.engine = engine; if (siteSearch) { if (!mSeparator ) { mSeparator = document.createElement("menuseparator"); mSeparator.setAttribute(siteSearch, "true"); menuPopup.appendChild(mSeparator); } mItem.setAttribute("label", _localize(siteSearch) + " - " + engine.name); if (options.siteSearch.iconsOn) { mItem.setAttribute("src", engine.iconURI.spec); } mItem.setAttribute(siteSearch, "true"); } else { mItem.setAttribute("label", engine.name); mItem.setAttribute("src", engine.iconURI.spec); } menuPopup.appendChild(mItem); } for (let i in engines) { if (options.hideDefaultEngineInList && this.isCustomEngine && engines[i].name == customName || options.hideDefaultEngineInList && !this.isCustomEngine && engines[i].name == searchService.defaultEngine.name) { continue; } mItemCreate(engines[i]); } function siteSearch_mItemCreate() { var namesList = []; if (options.siteSearch.useDefaultNamesList) { let defaultNamesList = [ ["Google", ["Google"]], ["Yandex", ["Yandex", "Яндекс"]], ["Yahoo", ["Yahoo"]], ["Bing", ["Bing"]], ["DuckDuckGo", ["DuckDuckGo"]] ]; namesList = namesList.concat(defaultNamesList); } if (options.siteSearch.addCustomNames && Array.isArray(options.siteSearch.customNamesList)) { namesList = namesList.concat(options.siteSearch.customNamesList); } let i_skips = []; namesList.forEach(function(elem) { for (let i in engines) { if (i_skips.indexOf(i) != -1 || elem[1].indexOf(engines[i].name) == -1) continue; mItemCreate(engines[i], "siteSearch"); i_skips.push(i); break; } }); } if (options.siteSearch.enable) { siteSearch_mItemCreate(); } menuPopup.gObj = this; menuPopup.setAttribute("oncommand", "if (!event.target.engine) return; this.gObj.commandHandler(event);"); menuPopup.setAttribute("onclick", "checkForMiddleClick(this, event);"); addEventListener("popupshowing", this, false, menu); }, commandHandlerSearchImage: function(event) { var inBg = false; if (event.type == "click" && event.button && event.button == 1) { inBg = true; } var imageMenu = this.imageMenu; var link = event.target.link; var linkURI = link + encodeURIComponent(imageMenu.imageSrc); gBrowser.loadOneTab(linkURI, { relatedToCurrent: true, inBackground: inBg }); }, imageMenuPopup: function(e) { var imageMenu = this.imageMenu; imageMenu.hidden = !gContextMenu.onImage; var src = gContextMenu.mediaURL || gContextMenu.imageURL || gContextMenu.bgImageURL; if (!src || !(/^(ht|f)tps?:\/\//.test(src))) { imageMenu.hidden = true; return; } imageMenu.imageSrc = src; }, creatImageMenu: function() { var menu = document.createElement("menu"); this.imageMenu = menu; menu.setAttribute("id", "context-image-search"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("label", _localize("searchImage")); menu.setAttribute("image", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAElSURBVDiNY/z//z8DJYCRkIKsthv/kRX9Z2BgmFalARdiIcaGKZXqcH5O+01U+ay2G3MYGBiSiXUmmofnsBDSjEUTMkiBe2Eq1JnZ7TcZBHhZGNythBl0lLkZODmYGX7++sdw/sZnhl3H3zF8+voHwwsYFkR5ijNICLMzTF31hOHnr38MHGxMDJlhMgwv3vxkWL7jJYpaJmzu0lTigWtmYGBg+PHrH8P0VU8YtJV5MNRiNYCfmxmuGQZ+/PrHwMmOqRyrAX///WfgYEOV4mBjwjAUpwHHL31iyA6XgRvCwcbEkBUmw3DuxmcMtVgDkYONicHLVoTBSJOXgYONieHHz38Ml+98Ydh88DXDtx//CBtACmBiYGCYS4H+OYyU5kasgUgKAADN8WLFzlj9rgAAAABJRU5ErkJggg=="); var mInsNode = document.getElementById("context-sep-copyimage"); mInsNode.parentNode.insertBefore(menu, mInsNode); var menuPopup = menu.appendChild(document.createElement("menupopup")); var mItemsList = [ [ "Google", "https://www.google.com/searchbyimage?image_url=", "data:image/x-icon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAA9IVCSvSFQuf0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULk9IVCSvSFQub0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQuf0hUL/9IVC//SFQv/0hUL/9Y1O//rIq//+7+f//eXX//vUvf/7z7X/96Fu//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vYwv/97OH/9ZRZ//SFQv/0hUL/9IhG//zbx//3om7/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97uX/+buW//SFQv/0hUL/9IVC//SFQv/5upT/+9O6//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+b6b//zezP/0iEf/9IVC//SFQv/1klf//ezh//vPtP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/3qXr/+siq//m8lv/5wqD//vTu//3t4//1klb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0h0b//vbx//zi0//1j1H/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2nmn/+bmS/////v/4sIX/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5uJH///v5//eoef/1jU//+82y//afav/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vXw//vOs//0hUL/9IVC//ekcf/96+D/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//728v/4sIX/9IVC//SFQv/4s4n///v4//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/6yKn/+byX//SFQv/0hkT//eTV//vWv//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IZE//m6lP/5u5b//OHQ///+/f/6y6//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vLr///7+P///Pv//vTu//3n2v/6zbH/96Nw//SFQ//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ekcv/+8+z////////////+9fD/+9K5//m9mf/4to7/+buV//vSuf/++PT//OPT//aYYP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2l13///r3/////////fv/+b2Z//SIRv/0hUL/9IVC//SFQv/0hUL/9IVC//WNT//84M///vXv//aZYf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vPtP////////////i0i//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//WQUv///Pr//OPU//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//eTV///////+9O7/9IVD//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//3m2P//////9ppi//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/718H///////3s4f/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vDn///////4soj/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//erff////////38//WTWP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//iziv////////////iwhf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//rMsP///////eXW//WSVv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/4sYb///z7/////////Pv/9ZFV//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ixhv/+8Of//vn1//rMsP/4rH//9plh//WQUv/1j1L/+s2x//////////////////m9mf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SGQ//2nmn/+buW//vNsv/82sb//e3j/////////////////////v/5wZ//9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/83Mj////////////++fb/+K+C//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9ZRZ/////////////vTt//aaYv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/1lFr////////////6xqf/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ehbf/70bj//end//3o2////v3///////3l1//0iEb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5wqD////////////96t7/96Z2//WOUP/2nWf//NvH//zcyP/1i0z/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/96l6/////////////vLr//WPUf/0hUL/9IVC//SFQv/0h0b//end//3k1f/0iUn/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/8387////////////4sYf/9IVC//SFQv/0hUL/9IVC//SFQv/6w6L///////nBn//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC///69////////vj1//SIR//0hUL/9IVC//SFQv/0hUL/9IVC//m+mv///////e3j//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL///r3///////8387/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+syw///////++fb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/95NX///////vUvP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97OH///////7y6//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//i2jv///////N/O//SFQv/0hUL/9IVC//SFQv/0hUL/96Nx////////////+s2x//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IdF//zh0P//+/j/9ZJW//SFQv/0hUL/9IVC//SKSv/96t7///////738v/1k1f/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9YxN//vUvf/96+D/96Z0//WNT//3om///ebY/////////Pv/+LKI//WVW//0h0X/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//agbP/7zbL//enc//749P////////////////////////////3r4P/3p3f/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULx9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC8/SFQq30hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUKt9IVCJ/SFQu/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC7/SFQif0hUIA9IVCJfSFQq30hULx9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC8fSFQq30hUIl9IVCAIAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAB" ], [ "Yandex", "http://images.yandex.ru/yandsearch?rpt=imagedups&text=&img_url=", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAkdx+AJHc5wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3JYArvIAAK7yAACu8gAArvIAA5Pd5wCr8P8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8CnOT/A5PdewCu8gAArvIAAK7yAAeV3/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/Aa3x/weW4P8Hld8PALDzAACw8wAMmOH///////////////////////////////////////////////////////////8GpOr/DJjhigCy9AAAsvQAEZzk//////8VpOn/Fbr1/xW69f+c4fv/ddb5/xW69f8VuvX/Fbr1/x2o6v//////AbT0/w+f5v8RnOQ8ALX1ABeg5v//////F6bp/xe48/8XuPP/hdf3/4XX9/80wPT/F7jz/xe48/8dqOr//////wC49v8IsPD/F6DmpQC49gAepOn//////wOe6P8DrvD/A67w/1/G8/9fxvP/TsLy/wSu8P8DrvD/CaHo//////8Au/j/ALv4/xep7f8epOlmJKjs//////9GvfD/ft78/37e/P///////////+f5/v+A3/z/ft78/03A8P//////AL75/wC++f8Huvf/JKjszyut7///////OLvw/2Pa/P9j2vz///////////+R5f3/Y9r8/2Pa/P8/vvD//////wDC+v8Awvr/CL74/yut788xsfL//////ya48P9F1fz/RdX8///////N8/7/RdX8/0XV/P9F1fz/Lrnw//////8Axfv/AMX7/yW29P8xsfJmOLX1//////8XtfD/KNH8/yjR/P/8/v//UNr9/yjR/P8o0fz/KNH8/x+48P//////AMn8/xTC+v84tfWlAMn8AD659///////ALHw/wCx8P8AsfD/Gbjw/wCx8P8AsfD/ALHw/wCx8P8JtPD//////wPM/v83u/j/Prn3PADN/gBDvfr///////////////////////////////////////////////////////////8lxvz/Q736igTR/gAE0f4ASMD8/xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8Y0///R8D8/0jA/A8S1f8AEtX/AEzD/uRa2f//XNz//1zc//9c3P//XNz//1zc//9c3P//XNz//1zc//9c3P//Ucv+/0zD/nhc3P8AXNz/AFzc/wBPxf97T8X/5E/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F/5Zc3P8AXNz/AFzc/wBc3P8AAA8AAAAHAAAAAwAAAAMAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAMAAAADAAAABwAAAA8AAA==" ], [ "TinEye", "http://www.tineye.com/search/?pluginver=firefox-1.0&url=", "data:image/x-icon;base64,AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAACxeDVItHk157iAO//WtW7/482G/+XOhv/lzYL/1L98/5mTcf8UKUP/CwsM/xwcG/8AAAD/AAAA/wAAAOcAAA5ItHo25LV7Nv+1ezb/tXs2/8GPSf/EoGj/s5hw/6KPdf93bWT/ZFdK/2daTP9hVEj/XU9C/zIpH/8EAgH/AAAA5LV7Nv+1ezb/tXs2/7V7Nv+1ezb/uIA+/8eea//Wtof/48eU/+PKkv/iyJP/4MeV/9u/kf/HqHz/rI1p/3tmT/+1ezb/tXs2/7V7Nv+1ezb/zKV0/+PKlP/hxXr/zbFk/8esYf/VuW7/3sFz/+LFdf/gw3P/48Z3/+nPjv/dwJD/tXs2/7V7Nv+1ezb/y6Nx/9/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" ] ]; function mItemCreate(name, link, image) { var mItem = document.createElement("menuitem"); mItem.setAttribute("class", "menuitem-iconic"); mItem.setAttribute("src", image); mItem.setAttribute("label", name); mItem.link = link; menuPopup.appendChild(mItem); } mItemsList.forEach(function(elem) { mItemCreate(elem[0], elem[1], elem[2]); }); var contextMenu = this.contextMenu; menuPopup.gObj = this; menuPopup.setAttribute("oncommand", "this.gObj.commandHandlerSearchImage(event);"); menuPopup.setAttribute("onclick", "checkForMiddleClick(this, event);"); addEventListener("popupshowing", this, false, contextMenu); } } contextSearcherObj.init(); })();
Отредактировано 2k1dmg (25-09-2013 16:47:42)
Отсутствует
bunda1
Убрал изменение меню при закрытии и
добавил "Поиск по изображени"
Получается отличная кнопка, но было бы не плохо если меню поисковиков открывалась и в текстовых полях, для этого можно поставить наблюдатель на пункт Копировать в контекстном меню страницы:
var copy = document.getElementById('context-copy'); var observeStatus = new MutationObserver(function() { menu.hidden = copy.hidden || copy.disabled; }); observeStatus.observe( copy, { attributes: true, attributeFilter: ["hidden", "disabled"] } ); addDestructor(function() { observeStatus.disconnect() });
И мне кажется код для отслеживания изменения поисковиков в about:config можно сделать компактней:
var s = 'browser.search.'; gPrefService.addObserver( s, this, false ); addDestructor(function() { gPrefService.removeObserver( s, this, false ) });
И наверно можно обойтись одним обработчиком:
Отредактировано bunda1 (25-09-2013 20:50:30)
Отсутствует
hideDefaultEngineInList: true
Извини, не заметил.
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует
Создана новая кнопка и по умолчанию скрыта = скрипт не работает.
А теперь вопрос: можно ли сделать, чтобы она работала или это ограничения дополнения/браузера?
upd:
в http://forum.mozilla-russia.org/viewtop … 09#p628009 показываются только 3 поиска по сайту (Google, Yandex, Bing), должно же быть пять или нет?
} function siteSearch_mItemCreate() { var namesList = []; if (options.siteSearch.useDefaultNamesList) { let defaultNamesList = [ ["Google", ["Google"]], ["Yandex", ["Yandex", "Яндекс"]], ["Yahoo", ["Yahoo"]], ["Bing", ["Bing"]], ["DuckDuckGo", ["DuckDuckGo"]] ]; namesList = namesList.concat(defaultNamesList); }
+
Сделайте пожалуйста, чтобы учитывало эту настройку - user_pref("browser.search.context.loadInBackground", true);
Отредактировано Northtech (08-10-2013 18:56:35)
Отсутствует
Northtech, если у тебя в панели поиска не присутствуют эти поисковики или их названия отличаются от указанных в коде , то они не будут отображаться в контекстном меню.
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует
Northtech, если у тебя в панели поиска не присутствуют эти поисковики или их названия отличаются от указанных в коде , то они не будут отображаться в контекстном меню.
Ага, спасибо, поисковики присутствуют, но названия другие.
Но насчет настройки (browser.search.context.loadInBackground) пожелание все же остаётся.
Отсутствует
Northtech
только вместо browser.search.context.loadInBackground
добавил options.loadInBackground
(function () { // Context Search mini 2013-10-09 var options = { loadInBackground: false, // true - открывать вкладки в фоне pinnedEngineName: "", // оставить пустым если не нужно закреплять // определенный поисковик // примеры pinnedEngineName: "Google" или pinnedEngineName: "Яндекс" или pinnedEngineName: "" hideDefaultEngineInPopupSubMenu: false, // true - не добавлять поисковик по умолчанию в выпадающий список (подменю) поисковиков campactMenu: true, // true - поисковики в выпадающем списке (подменю) без назаваний campactMenuLengthPerLine: 5, // максимальное количество элементов в одной строке // от 3 до 10, по умолчанию 5 searchBySite: { enable: true, // true - добавить поисковики по сайту iconsOn: true, // true - добавить иконки для поисковиков по сайту useDefaultNamesList: true, // true - использовать список поисковиков по умолчанию addCustomNames: false, // true - добавить свои поисковики по сайту customNamesList: [ ["Rambler", ["Rambler", "Рамблер"]] ] // например ["Rambler", ["Rambler", "Рамблер"]] // первая ячека название на английском // вторая ячека массив с предполагаемыми именами поисковика // может состоять из нескольких значений // ["Name1", ["Name1"]], // ["Name2", ["Name2", "Имя2"]], // ["Name3", ["Name3", "Имя3", "Név3"]] }, searchImageByText: { enable: true, // true - добавить поиск изображения по тексту useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] }, searchByImage: { enable: true, // true - добавить поиск по изображению useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] }, searchInCache: { enable: true, // true - добавить поиск в кэше // нужно доработать useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] } }; function _localize(sid) { let strings = { en: { searchBySite: "Search this site", searchImageByText: "Search image by text", searchByImage: "Search by image", searchInCache: "Search this page in cache" }, ru: { searchBySite: "Поиск по этому сайту", searchImageByText: "Поиск изображения по тексту", searchByImage: "Поиск по изображению", searchInCache: "Поиск этой страницы в кэше" } }; //let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; function getBrowserUILocale() { // Browser UI locale return Components.classes["@mozilla.org/chrome/chrome-registry;1"] .getService(Components.interfaces.nsIXULChromeRegistry) .getSelectedLocale("global"); } let locale = ""; // ru, en if (!locale || locale == "") locale = getBrowserUILocale().match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; let XHTMLNS = "http://www.w3.org/1999/xhtml" var contextSearcherObj = { initialized: false, init: function() { if(this.initialized) return; this.initialized = true; this.nodeIds = { searchMenu: "contextSearchMiniByBunda1-menu", searchMenuPopup: "contextSearchMiniByBunda1-popup", searchByImageMenu: "contextSearchMiniByBunda1-image-search-menu", searchByImageMenuPopup: "contextSearchMiniByBunda1-image-search-popup" }; if (document.getElementById(this.nodeIds.searchMenu)) return; var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var contextMenu = document.getElementById("contentAreaContextMenu"); var searchSelect = document.getElementById("context-searchselect"); searchSelect.style.display = "none"; var searchMenu = contextMenu.insertBefore(document.createElementNS(XULNS, "menu"), searchSelect); this.searchService = searchService; this.contextMenu = contextMenu; this.searchSelect = searchSelect; this.searchMenu = searchMenu; this.param = { isPinnedEngine: false, pinnedEngineName: "" }; try { this.createSearchMenu(); if (options.searchByImage.enable) this.createSearchByImageMenu(); } catch (ex) { this.destroy(); Components.utils.reportError(ex); return; } if (options.campactMenu) this.loadStyles(); var observeStatus = new MutationObserver(function () { searchMenu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); /*var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); this.branch = prefService.getBranch("browser.search."); if (!("addObserver" in this.branch)) this.branch.QueryInterface(Components.interfaces.nsIPrefBranch2); this.branch.addObserver("", this, false);*/ /* var searchPref = "browser.search."; gPrefService.addObserver(searchPref, this, false);*/ let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); os.addObserver(this, "browser-search-engine-modified", false); Services.ww.registerNotification(this); addEventListener("popupshowing", this, false, contextMenu); addDestructor(function (reason) { observeStatus.disconnect(); Services.ww.unregisterNotification(this); //this.branch.removeObserver("", this); //gPrefService.removeObserver(searchPref, this, false); os.removeObserver(this, "browser-search-engine-modified", false); this.destroy(); if (reason != "destructor") this.unloadStyles(); }, this); }, destroy: function() { if(!this.initialized) return; this.initialized = false; var contextMenu = this.contextMenu; if (!contextMenu) return; if (this.searchMenu) contextMenu.removeChild(this.searchMenu); if (this.searchByImageMenu) contextMenu.removeChild(this.searchByImageMenu); if (this.searchSelect) this.searchSelect.style.removeProperty("display"); }, update: function() { this.searchMenu.textContent = ""; this.createSearchMenu(); }, get isSeaMonkey() { delete this.isSeaMonkey; return this.isSeaMonkey = Services.appinfo.name == "SeaMonkey"; }, observe: function(subject, topic, data) { switch (topic) { case "domwindowclosed": if (subject.document.documentElement.getAttribute("windowtype") == "Browser:SearchManager") { this.update(); } break; /*case "nsPref:changed": switch (data) { case "defaultenginename": case "browser.search.defaultenginename": this.update(); break; } break;*/ case "browser-search-engine-modified": switch (data) { case "engine-current": // engine-default case "engine-changed": case "engine-removed": this.update(); break; } break; } }, handleEvent: function(e) { //var contextMenu = this.contextMenu; //var menu = this.menu; //var imageMenu = this.imageMenu; switch (e.type) { case "popupshowing": this.popupshowingEvent(e); break; } }, popupshowingEvent: function(e) { var trgId = e.target.id; if (trgId) { if (trgId == "contentAreaContextMenu") { this.contextMenuPopup(e); if (this.searchByImageMenu) this.searchByImageMenuPopup(e); } else if (trgId == this.nodeIds.searchMenuPopup) this.searchMenuPopup(e); } }, _stylesLoaded: false, loadStyles: function() { if(this._stylesLoaded) return; this._stylesLoaded = true; var sss = this.sss; var cssURI = this.cssURI = this.makeCSSURI(); if(!sss.sheetRegistered(cssURI, sss.USER_SHEET)) sss.loadAndRegisterSheet(cssURI, sss.USER_SHEET); }, unloadStyles: function() { if(!this._stylesLoaded) return; this._stylesLoaded = false; var sss = this.sss; if(sss.sheetRegistered(this.cssURI, sss.USER_SHEET)) sss.unregisterSheet(this.cssURI, sss.USER_SHEET); }, get sss() { delete this.sss; return this.sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService); }, makeCSSURI: function() { var cssStr = '\ @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n\ @-moz-document url("' + window.location.href + '") {\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] {\n\ /*width: 2em !important;*/\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] * {\n\ /*padding-left: 0 !important;\n\ padding-right: 0 !important;\n\ margin-left: 0 !important;\n\ margin-right: 0 !important;*/\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > spacer[campactMenu="true"] {\n\ width: 2em !important;\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] {\n\ width: 3em !important;\n\ height: 2em !important;\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox >.menuitem-iconic[campactMenu="true"] > image {\n\ margin-left: .8em !important;\n\ }\n\ }\n\ '; return Services.io.newURI("data:text/css," + encodeURIComponent(cssStr), null, null); }, searchCommandHandler: function(event, trg) { var inBg = options.loadInBackground || false; if (event.type == "click" && event.button && event.button == 1) { inBg = !inBg; } var searchBySite = ""; if (event.target.hasAttribute("searchBySite")) { searchBySite = " site:" + gBrowser.currentURI.host; } else if (event.target.hasAttribute("searchInCache")) { searchBySite = content.location.href; } let selectedText = this.isSeaMonkey ? content.getSelection() : getBrowserSelection(); if (event.target.engine.imageLink) { gBrowser.loadOneTab(event.target.engine.imageLink + /*getBrowserSelection()*/ selectedText, { relatedToCurrent: true, inBackground: inBg }); } else if (event.target.engine.cacheLink) { gBrowser.loadOneTab(event.target.engine.cacheLink + /*getBrowserSelection()*/ searchBySite, { relatedToCurrent: true, inBackground: inBg }); } else { let submission = event.target.engine.getSubmission(/*getBrowserSelection()*/ selectedText + searchBySite, null); gBrowser.loadOneTab(submission.uri.spec, { relatedToCurrent: true, postData: submission.postData, inBackground: inBg }); } if (trg == "menu") { setTimeout(function () { document.getElementById("contentAreaContextMenu").hidePopup(); }, 0); } }, contextMenuPopup: function(e) { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.searchMenu; //var selectedText = getBrowserSelection(16); let selectedText = this.isSeaMonkey ? content.getSelection(16) : getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (ex) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; var engineName = this.param.isPinnedEngine ? this.param.pinnedEngineName : searchService.defaultEngine.name; var menuLabel; var searchFormattedString = [ "contextMenuSearch", "contextMenuSearchText", "searchSelected" ]; var _this = this; function getMenuLabel(str) { try { if (_this.isSeaMonkey) { let bundle = document.getElementById("contentAreaCommandsBundle"); return bundle.getFormattedString(str, [engineName, selectedText]); } else return gNavigatorBundle.getFormattedString(str, [engineName, selectedText]); } catch (ex) { return false; } } for(let i in searchFormattedString) { menuLabel = getMenuLabel(searchFormattedString[i]); if (menuLabel) break; else if (!menuLabel && i == searchFormattedString.length-1) menuLabel = engineName; } menu.label = menuLabel; }, searchMenuPopup: function(e) { var popup = e.target; var items; if (!popup.items) { var itemsObj = popup.getElementsByTagName("menuitem"); popup.items = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) popup.items.push(elem); }); items = popup.items; } else { items = popup.items; } var menus; if (!popup.menus) { var itemsObj = popup.getElementsByTagName("menu"); popup.menus = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menu" && elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) popup.menus.push(elem); }); menus = popup.menus; } else { menus = popup.menus; } var siteSearchDomain; var gBrowser = gBrowser || getBrowser(); function isDomain() { try { siteSearchDomain = gBrowser.currentURI.host; } catch (ex) { return false; } return true; } if (isDomain()) { items.forEach(function(elem) { //if (elem.hasAttribute("searchBySite")) // elem.setAttribute("tooltiptext", siteSearchDomain); elem.removeAttribute("disabled"); }); menus.forEach(function(elem) { if (elem.hasAttribute("searchBySite")) elem.setAttribute("tooltiptext", siteSearchDomain); else if (elem.hasAttribute("searchInCache")) elem.setAttribute("tooltiptext", content.document.title); elem.removeAttribute("disabled"); }); } else { items.forEach(function(elem) { //if (elem.hasAttribute("searchBySite")) // elem.removeAttribute("tooltiptext"); elem.setAttribute("disabled", "true"); }); menus.forEach(function(elem) { if (elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) elem.removeAttribute("tooltiptext"); elem.setAttribute("disabled", "true"); }); } }, createSearchMenu: function() { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.searchMenu; var engines = searchService.getVisibleEngines({}); menu.setAttribute("id", this.nodeIds.searchMenu); menu.setAttribute("class", "menu-iconic"); this.param.isPinnedEngine = false; this.param.pinnedEngineName = ""; var pinnedEngineName = options.pinnedEngineName; if (pinnedEngineName != "") { for (let i in engines) { if (engines[i].name != pinnedEngineName) continue; menu.setAttribute("label", engines[i].name); menu.setAttribute("image", engines[i].iconURI.spec); menu.engine = engines[i]; this.param.isPinnedEngine = true; this.param.pinnedEngineName = pinnedEngineName; break; } } if (!this.param.isPinnedEngine) { menu.setAttribute("label", searchService.defaultEngine.name); menu.setAttribute("image", searchService.defaultEngine.iconURI.spec); menu.engine = searchService.defaultEngine; } menu.gObj = this; menu.setAttribute("onclick", "if (event.target == this && event.target.engine) this.gObj.searchCommandHandler(event, 'menu');"); menu.popup = menu.appendChild(document.createElementNS(XULNS, "menupopup")); var popup = this.searchMenu.popup; popup.setAttribute("id", this.nodeIds.searchMenuPopup); var counterMaxLength = options.campactMenuLengthPerLine; if (typeof counterMaxLength != "number" || 3 > counterMaxLength || counterMaxLength > 10) counterMaxLength = 5; var counter = 0; var hBox; function itemCreateCampact(engine, last) { if(counter == 0) { hBox = document.createElementNS(XULNS, "hbox"); let item = document.createElementNS(XULNS, "spacer"); //item.setAttribute("style", "width: 2em"); item.setAttribute("campactMenu", "true"); hBox.appendChild(item); } counter++; var item = document.createElementNS(XULNS, "menuitem"); item.engine = engine; item.setAttribute("class", "menuitem-iconic"); item.setAttribute("tooltiptext", engine.name); //item.setAttribute("src", engine.iconURI.spec); var image = document.createElementNS(XULNS, "image"); image.setAttribute("src", engine.iconURI.spec); item.appendChild(image); //item.setAttribute("style", "max-width: 2em"); item.setAttribute("campactMenu", "true"); hBox.appendChild(item); if (counter == counterMaxLength || last) { popup.appendChild(hBox); counter = 0; } } var separator = {}; function itemCreate(engine, reason) { var item = document.createElementNS(XULNS, "menuitem"); item.setAttribute("class", "menuitem-iconic"); item.engine = engine; if (reason && !separator[reason]) { /*let sep = separator[reason] = document.createElementNS(XULNS, "menuseparator"); sep.setAttribute(reason, "true"); popup.appendChild(sep); let item = document.createElementNS(XULNS, "label"); //item.setAttribute("class", "menuitem-iconic"); item.setAttribute("value", _localize(reason) + ":"); item.setAttribute("style", "padding-left: 2em"); popup.appendChild(item);*/ if (!separator["menuseparator"]) { let sep = separator["menuseparator"] = document.createElementNS(XULNS, "menuseparator"); popup.appendChild(sep); } let subMenu = separator[reason] = document.createElementNS(XULNS, "menu"); subMenu.setAttribute("class", "menu-iconic"); subMenu.setAttribute("label", _localize(reason)); subMenu.setAttribute(reason, "true"); subMenu.popup = subMenu.appendChild(document.createElementNS(XULNS, "menupopup")); popup.appendChild(subMenu); } if (reason == "searchBySite") { item.setAttribute("label", engine.name); if (options.searchBySite.iconsOn) { item.setAttribute("src", engine.iconURI.spec); } item.setAttribute(reason, "true"); } else if (reason == "searchImageByText" || reason == "searchInCache") { item.setAttribute("label", engine.name); item.setAttribute("src", engine.iconURI_spec); item.setAttribute(reason, "true"); } else { item.setAttribute("label", engine.name); item.setAttribute("src", engine.iconURI.spec); } //popup.appendChild(item); if (reason) { let subMenu = separator[reason]; subMenu.popup.appendChild(item); } else popup.appendChild(item); } for (let i in engines) { if (options.hideDefaultEngineInPopupSubMenu && this.param.isPinnedEngine && engines[i].name == pinnedEngineName || options.hideDefaultEngineInPopupSubMenu && !this.param.isPinnedEngine && engines[i].name == searchService.defaultEngine.name) { continue; } if (options.campactMenu) itemCreateCampact(engines[i], i == engines.length-1); else itemCreate(engines[i]); } function searchBySite_itemCreate() { var namesList = []; if (options.searchBySite.useDefaultNamesList) { let defaultNamesList = [ ["Google", ["Google"]], ["Yandex", ["Yandex", "Яндекс"]], ["Yahoo", ["Yahoo"]], ["Bing", ["Bing"]], ["DuckDuckGo", ["DuckDuckGo"]] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchBySite.addCustomNames && Array.isArray(options.searchBySite.customNamesList)) { namesList = namesList.concat(options.searchBySite.customNamesList); } //let i_skips = []; function isNameExist(names, engine) { for (let i in names) { if (names[i] != engine && i != names.length-1) continue; else if (names[i] == engine) return true; return false; } } namesList.forEach(function(elem) { for (let i in engines) { if (/*i_skips.indexOf(i) != -1 ||*/ !(elem[1].some(function(listName) listName == engines[i].name)) /*!isNameExist(elem[1], engines[i].name)*/ /*elem[1].indexOf(engines[i].name) == -1*/) continue; itemCreate(engines[i], "searchBySite"); //i_skips.push(i); break; } }); } if (options.searchBySite.enable) { searchBySite_itemCreate(); } function searchImageByText_itemCreate() { var namesList = []; if (options.searchImageByText.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.ru/search?tbm=isch&q=", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB41BMVEUAAAB7wUJ6wUJ6wUJ6wUL1nxn1oBn1oBn1nxl6wUJ6wUJ6wUJrvUT1mxr1nxn1nxlfu0Z8wkLznhv0mhp6wUJWuUdaukfLrSv4rhX1nxl5wUJyv0TQrCnyjhz1kyH2pRj1oBl7wkNbukfzjR3zkxv1liHuMDXuGTf2rxN7wUJeu0apuDfzjhz1nBvuNizwZi/3sxP2pBh9wkGvuTbvoRvuJy/xcC33qRhbl7F2uGOMwT94havnRTzuMjjwTTNRislRjcZ5uVpnvU0rk9Fhjr3aTkPuLTVQkM1PgsKHxD9/w0JfnKsAouPtHCTvQDRRkM1Qjstfn6p2jLHvOzDvQDVQkM1Rkc1RjstOh8Z/h6buLirtGyTvOzHvQDXwQDVPkcftPzdRkc1QkMxRkM0xlNLuNSzwQDXvQDVQkM1Rkc1QkM1Rkc3vQDTvQDXvQDXwQDV7wUL2oBr1nxn2oBl6wUJ7wkN9wkF9wkJ6wUP0lRv3qhf1oBn4rhX3qhb1nhp8wkL0nBruGjLuIzf3qRZ/w0JcukbuLCntIzl+wkFkvEbtGyVPhMRyv0QAmNfuLCruMDVRkc1ViccKltTvQDVRhcUAmdfvQDRRks5RiskcltTwQzdQkM07k9DtGyPvQzdQkMzvPzSgiRCBAAAAcHRSTlMAM9bsfmzq30TnaEIQF1b390JR9nP98873iO4nsPyvO3Vly1783sVB8T/5j+2SiIXyKITTeqTRY0ThWl/g9jAn2cBPbNfJFWXVrOjTge5EeeC0qPBsYPfUstjGvOP+dnp0+pmBR1GEikvl8paC8etfYXu9TgAAAAlwSFlzAAAASAAAAEgARslrPgAAAQJJREFUGNM1j8VWQzEARAco8NDiLsXdXQvF3d3dIQ2vOBR3CQSCFPtUUg7Mbu5i7hnY2Npp8Bd7B0cFToQQZxdXwE1xN9JVLVRiUsmah6eXNzVKQOFD1PUNXz//za0ASul2IKBRg4IREroThnAt1cmlCFMkoqJ3Y2LjEL+nSJBgTkxK3k9JPThMSz/KsMoyj0+ysoGc07PcvF97fsH5RSFQVHxZUmrt+quycvO1oeKmsur2rlqCGlaLuvqG+4dGNPFmCVpYK9D2+NQOdIhOoKubPff0vrz29Q8MvvGhYTAZC3sfGf34FFwIgTHLFxufmASmpme+OeeYnZtf+L+/uLS88gMT2kW5QAjbFwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMi0wNC0wNlQxMDoxMzowNSswNDowMIQ8zwwAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTItMDQtMDZUMTA6MTM6MDUrMDQ6MDD1YXewAAAAAElFTkSuQmCC" ], [ "Yandex", "http://images.yandex.ru/yandsearch?text=", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAkdx+AJHc5wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3JYArvIAAK7yAACu8gAArvIAA5Pd5wCr8P8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8CnOT/A5PdewCu8gAArvIAAK7yAAeV3/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/Aa3x/weW4P8Hld8PALDzAACw8wAMmOH///////////////////////////////////////////////////////////8GpOr/DJjhigCy9AAAsvQAEZzk//////8VpOn/Fbr1/xW69f+c4fv/ddb5/xW69f8VuvX/Fbr1/x2o6v//////AbT0/w+f5v8RnOQ8ALX1ABeg5v//////F6bp/xe48/8XuPP/hdf3/4XX9/80wPT/F7jz/xe48/8dqOr//////wC49v8IsPD/F6DmpQC49gAepOn//////wOe6P8DrvD/A67w/1/G8/9fxvP/TsLy/wSu8P8DrvD/CaHo//////8Au/j/ALv4/xep7f8epOlmJKjs//////9GvfD/ft78/37e/P///////////+f5/v+A3/z/ft78/03A8P//////AL75/wC++f8Huvf/JKjszyut7///////OLvw/2Pa/P9j2vz///////////+R5f3/Y9r8/2Pa/P8/vvD//////wDC+v8Awvr/CL74/yut788xsfL//////ya48P9F1fz/RdX8///////N8/7/RdX8/0XV/P9F1fz/Lrnw//////8Axfv/AMX7/yW29P8xsfJmOLX1//////8XtfD/KNH8/yjR/P/8/v//UNr9/yjR/P8o0fz/KNH8/x+48P//////AMn8/xTC+v84tfWlAMn8AD659///////ALHw/wCx8P8AsfD/Gbjw/wCx8P8AsfD/ALHw/wCx8P8JtPD//////wPM/v83u/j/Prn3PADN/gBDvfr///////////////////////////////////////////////////////////8lxvz/Q736igTR/gAE0f4ASMD8/xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8Y0///R8D8/0jA/A8S1f8AEtX/AEzD/uRa2f//XNz//1zc//9c3P//XNz//1zc//9c3P//XNz//1zc//9c3P//Ucv+/0zD/nhc3P8AXNz/AFzc/wBPxf97T8X/5E/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F/5Zc3P8AXNz/AFzc/wBc3P8AAA8AAAAHAAAAAwAAAAMAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAMAAAADAAAABwAAAA8AAA==" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchImageByText.addCustomNames && Array.isArray(options.searchImageByText.customNamesList)) { namesList = namesList.concat(options.searchImageByText.customNamesList); } namesList.forEach(function(elem) { let engine = {}; engine.name = elem[0]; engine.imageLink = elem[1]; engine.iconURI_spec = elem[2]; itemCreate(engine, "searchImageByText"); }); } if (options.searchImageByText.enable) { searchImageByText_itemCreate(); } function searchInCache() { var namesList = []; if (options.searchInCache.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.com/search?q=cache:", "data:image/x-icon;base64,AAABAAIAEBAAAAAAAAB9AQAAJgAAACAgAAAAAAAA8gIAAKMBAACJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAFESURBVDjLpZNJSwNBEIXnt4lE4kHxovgT9BDwJHqPy0HEEOJBiAuCRg+KUdC4QS4KrpC4gCBGE3NQ48JsnZ6eZ3UOM6gjaePhQU93v6+qq2q0pqgeJj2S8EdJT1hr0OxBtKCD5iEd8QxDYpvhvOBAuMDKURX9C9aPu4GA1GEVkzvMg10UBfYveWAWgYAP00V01fa+R9M2bA51wJvhIn3qR+ybt3D3JNQBE5sMjCIOLFpoHzOwdsLRO22qA6R6kiZiWwxUvy/PUQZIhYZ1vFM9cvcOOsYNdcBgysISdSJBnZjJMlR0Fw8vAp0xoz5gao/h+NZBy4i/10XGwrPA+hmvDyhVRG2Avu/LwcrkFADZa16L1h330w1RNgc3DiJzCpPYRm1bpveXX11clQR28xwblHpk1vq1iP/5mcoS0CoXDZiL0vsJ+dzfl+3T/VYAAAAASUVORK5CYIKJUE5HDQoaCgAAAA1JSERSAAAAIAAAACAIBgAAAHN6evQAAAK5SURBVFjDxVfrSxRRFJ9/Jta/oyWjF5XQm6D6EkHRgygIIgjUTcueVgqVWSRRkppEUQYWWB8ye1iGWilWlo/Ude489s7M6Zw7D9dlt53dmd29cFiWvXvO77x+51xpaaUsoSxBaUWZQ4ECy5xji2xKZDyCMlMEw6lCNiOSgwZKJK1SkcKeSealfP64t0mBjl4Ow39MkDUL0p2RSROOtqhZdeUEYM1pBl39XCg/fEeFtWcY7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gIC/wICAv8BAQH/AAAA/wEBAf8CAgL/AAAA/wUFBf+rq6v/7Ozs/3V1df8AAAD/AAAA/zs7O//j4+P/4uLi/zo6Ov8AAAD/AAAA/wQEBP+rq6v/7Ozs/4WFhf8AAAD/AAAA/zw8PP/k5OT/4+Pj/zk5Of8AAAD/BQUF/wAAAP8BAQH/AQEB/wAAAP8BAQH/AAAA/wMDA/8AAAD/ISEh/+Hh4f//////uLi4/wkJCf8CAgL/bW1t////////////bW1t/wICAv8CAgL/ISEh/+Hh4f//////wMDA/woKCv8CAgL/bW1t////////////bW1t/wEBAf8HBwf/AgIC/wEBAf8AAAD/AQEB/wEBAf8AAAD/AwMD/wAAAP8cHBz/2NjY//////+4uLj/BwcH/wAAAP9lZWX//f39//////9nZ2f/AAAA/wAAAP8ZGRn/2dnZ//////+3t7f/CAgI/wAAAP9oaGj//Pz8//7+/v9mZmb/AAAA/wYGBv8AAAD/AgIC/wEBAf8BAQH/AwMD/wICAv8BAQH/AAAA/xsbG//Y2Nj//////7i4uP8GBgb/AAAA/2pqav///////v7+/2VlZf8AAAD/AAAA/xsbG//Y2Nj//////7m5uf8HBwf/AAAA/2VlZf///////////2VlZf8AAAD/BQUF/wEBAf8DAwP/AQEB/wAAAP8AAAD/AAAA/wQEBP8AAAD/HR0d/9ra2v//////urq6/wgICP8AAAD/Z2dn////////////aGho/wAAAP8AAAD/HR0d/9vb2///////urq6/wcHB/8AAAD/aGho////////////aWlp/wAAAP8FBQX/AAAA/wEBAf8BAQH/AAAA/wAAAP8AAAD/AgIC/wAAAP8cHBz/29vb//////+4uLj/BgYG/wAAAP9mZmb///////////9nZ2f/AAAA/wAAAP8aGhr/2tra//////+4uLj/BwcH/wAAAP9lZWX///////////9mZmb/AAAA/wUFBf8AAAD/AAAA/wAAAP8AAAD/AAAA/wEBAf8DAwP/AAAA/xwcHP/a2tr//////7i4uP8GBgb/AAAA/2ZmZv///////////2dnZ/8AAAD/AAAA/xsbG//b29v//////7m5uf8JCQn/AAAA/2hoaP///////////2dnZ/8AAAD/BQUF/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wMDA/8AAAD/Ghoa/9nZ2f//////ubm5/wYGBv8AAAD/ZmZm////////////ZmZm/wAAAP8AAAD/Gxsb/9ra2v//////uLi4/wcHB/8AAAD/ZmZm//7+/v/+/v7/ZmZm/wAAAP8EBAT/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AwMD/wAAAP8aGhr/2NjY//////+6urr/BgYG/wAAAP9mZmb///////////9mZmb/AAAA/wAAAP8aGhr/2NjY//////+5ubn/BwcH/wAAAP9nZ2f//v7+//////9nZ2f/AAAA/wQEBP8AAAD/AAAA/wAAAP8AAAD/AAAA/wEBAf8DAwP/AAAA/xwcHP/a2tr//////7q6uv8HBwf/AAAA/2ZmZv///////////2ZmZv8AAAD/AAAA/xoaGv/Y2Nj//////7i4uP8GBgb/AAAA/2ZmZv/9/f3//v7+/2ZmZv8AAAD/BAQE/wAAAP8AAAD/AAAA/wAAAP8AAAD/AQEB/wMDA/8AAAD/HBwc/9vb2///////urq6/wgICP8AAAD/ZmZm////////////Z2dn/wAAAP8AAAD/Gxsb/9nZ2f//////urq6/wcHB/8AAAD/Z2dn////////////Z2dn/wAAAP8EBAT/AAAA/wAAAP8AAAD/AAAA/wAAAP8CAgL/BAQE/wAAAP8dHR3/29vb//////+8vLz/BwcH/wAAAP9nZ2f///////////9mZmb/AAAA/wAAAP8bGxv/29vb//////+6urr/BgYG/wAAAP9nZ2f///////////9mZmb/AAAA/wYGBv8AAAD/AQEB/wEBAf8AAAD/AQEB/wMDA/8DAwP/AAAA/x0dHf/a2tr/+fn5/7CwsP8GBgb/AAAA/2pqav/5+fn/+fn5/2tra/8AAAD/AAAA/xwcHP/Z2dn/+fn5/7m5uf8JCQn/AAAA/2xsbP/5+fn/+fn5/2tra/8AAAD/BwcH/wEBAf8CAgL/AQEB/wEBAf8CAgL/AwMD/wMDA/8AAAD/FxcX/9zc3P//////l5eX/wcHB/8DAwP/YGBg////////////XFxc/wQEBP8FBQX/GBgY/97e3v//////s7Oz/wkJCf8EBAT/XV1d////////////W1tb/wEBAf8EBAT/AQEB/wMDA/8DAwP/AAAA/wEBAf8DAwP/AQEB/wEBAf8AAAD/LS0t/1RUVP8hISH/AAAA/wAAAP8BAQH/TExM/0tLS/8AAAD/AAAA/wAAAP8AAAD/LS0t/1NTU/8bGxv/AAAA/wAAAP8BAQH/TExM/0tLS/8BAQH/AAAA/wEBAf8AAAD/AQEB/wAAAP8CAgL/AQEB/wEBAf8AAAD/BwcH/8XFxf++vr7/tbW1/729vf/Kysr/y8vL/8fHx/+2trb/tra2/8bGxv/Ly8v/yMjI/8rKyv+7u7v/tbW1/8DAwP/Ly8v/y8vL/8XFxf+1tbX/srKy/8nJyf9PT0//AAAA/wYGBv8CAgL/AAAA/wEBAf8AAAD/AQEB/wEBAf8KCgr//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3Jycv8AAAD/BwcH/wEBAf8DAwP/AQEB/wAAAP8BAQH/AAAA/wgICP95eXn/fX19/319ff9/f3//gICA/4CAgP+BgYH/gICA/39/f/+BgYH/gYGB/4CAgP+AgID/gICA/4GBgf+AgID/gICA/4GBgf9/f3//fX19/3l5ef9+fn7/MjIy/wAAAP8DAwP/AQEB/wEBAf8AAAD/AQEB/wICAv8AAAD/BgYG/4+Pj/+Tk5P/j4+P/4uLi/+Hh4f/hISE/4ODg/+CgoL/gYGB/4KCgv+CgoL/goKC/4KCgv+BgYH/f39//39/f/+EhIT/hoaG/4eHh/+MjIz/kpKS/5WVlf8uLi7/AAAA/wMDA/8AAAD/AAAA/wEBAf8AAAD/AQEB/wQEBP8EBAT/SUlJ/1RUVP+BgYH/wsLC/////////////////////////////////////////////////////////////////////////////f39/6+vr/9iYmL/S0tL/xkZGf8AAAD/AwMD/wEBAf8DAwP/AQEB/wEBAf8BAQH/AAAA/wYGBv8AAAD/AAAA/wAAAP8AAAD/AQEB/wgICP9RUVH/paWl/8rKyv/a2tr/+fn5///////5+fn/2tra/8vLy/+ampr/T09P/xQUFP8DAwP/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AQEB/wEBAf8CAgL/AQEB/wICAv8BAQH/AAAA/wQEBP8EBAT/AwMD/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/xsbG/9nZ2f/i4uL/2dnZ/8ZGRn/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AgIC/wQEBP8CAgL/AgIC/wAAAP8DAwP/AgIC/wEBAf8AAAD/AQEB/wEBAf8AAAD/AgIC/wICAv8BAQH/AgIC/wMDA/8DAwP/AgIC/wQEBP8HBwf/AAAA/wAAAP8AAAD/AAAA/wAAAP8HBwf/BQUF/wMDA/8BAQH/AQEB/wMDA/8CAgL/AQEB/wEBAf8CAgL/AQEB/wAAAP8CAgL/AgIC/wICAv8AAAD/AAAA/wMDA/8CAgL/AwMD/wMDA/8BAQH/AQEB/wUFBf8DAwP/AgIC/wAAAP8EBAT/BwcH/wcHB/8HBwf/BAQE/wICAv8BAQH/AgIC/wEBAf8BAQH/AgIC/wICAv8BAQH/AAAA/wEBAf8AAAD/AgIC/wICAv8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchInCache.addCustomNames && Array.isArray(options.searchInCache.customNamesList)) { namesList = namesList.concat(options.searchInCache.customNamesList); } namesList.forEach(function(elem) { let engine = {}; engine.name = elem[0]; engine.cacheLink = elem[1]; engine.iconURI_spec = elem[2]; itemCreate(engine, "searchInCache"); }); } if (options.searchInCache.enable) { searchInCache(); } popup.gObj = this; //popup.setAttribute("oncommand", "if (!event.target.engine) return; var csObj = this.gObj || document.getElementById('contextSearchMiniByBunda1-context-popup').gObj; csObj.searchCommandHandler(event);"); popup.setAttribute("oncommand", "if (!event.target.engine) return; this.gObj.searchCommandHandler(event);"); popup.setAttribute("onclick", "checkForMiddleClick(this, event);"); }, searchByImageCommandHandler: function(event) { var inBg = options.loadInBackground || false; if (event.type == "click" && event.button && event.button == 1) { inBg = !inBg; } var searchByImageMenu = this.searchByImageMenu; var link = event.target.link; var imageLink = searchByImageMenu.imageSrc; if (imageLink.indexOf("data:") == 0) { this.searchByImageByData(imageLink, inBg); return; } else if (imageLink.indexOf("file:") == 0) { this.searchByImageByFile(imageLink, inBg); return; } else { imageLink = encodeURIComponent(imageLink) } var gBrowser = gBrowser || getBrowser(); gBrowser.loadOneTab(link + imageLink, { relatedToCurrent: true, inBackground: inBg }); }, // searchByImageByData() and searchByImageByFile() based on // Google Image Search 0.5 by Nishan Naseer // https://addons.mozilla.org/ru/firefox/addon/google-similar-images searchByImageByData: function(src, inBg) { var gBrowser = gBrowser || getBrowser(); //var tab = gBrowser.addTab(this.searchByImageMenu.popup.googleURL); var tab = gBrowser.loadOneTab(this.searchByImageMenu.popup.googleURL, { relatedToCurrent: true }); var newTabBrowser = gBrowser.getBrowserForTab(tab); newTabBrowser.addEventListener("load", function byData(e) { newTabBrowser.removeEventListener(e.type, byData, true); if (src) { try { var image_url; var sub; var form = newTabBrowser.contentDocument.getElementById("qbf"); var inputs = form.getElementsByTagName("input"); for (var k = 0; k < inputs.length; k++) { var i = inputs[k]; if (i.name && i.name == "image_url") { image_url = i; } if (i.type && i.type == "submit") { sub = i; } } image_url.value = src; sub.click(); src = null; } catch (ex) { } } }, true); if (!inBg) { getBrowser().selectedTab = tab; } }, searchByImageByFile: function(src, inBg) { //Canvas to get contents in base-64 var canvas = gContextMenu.target.ownerDocument.createElementNS(XHTMLNS, "canvas"); var image = new Image(); image.src = src; canvas.width = image.width; canvas.height = image.height; var ctx = canvas.getContext("2d"); ctx.drawImage(image, 0, 0); var dataURL = canvas.toDataURL("image/png"); var gBrowser = gBrowser || getBrowser(); //var tab = gBrowser.addTab(this.searchByImageMenu.popup.googleURL); var tab = gBrowser.loadOneTab(this.searchByImageMenu.popup.googleURL, { relatedToCurrent: true }); var newTabBrowser = gBrowser.getBrowserForTab(tab); newTabBrowser.addEventListener("load", function byFile(e) { newTabBrowser.removeEventListener(e.type, byFile, true); if (src) { try { var image_url; var sub; var form = newTabBrowser.contentDocument.getElementById("qbf"); var inputs = form.getElementsByTagName("input"); for (var k = 0; k < inputs.length; k++) { var i = inputs[k]; if (i.name && i.name == "image_url") { image_url = i; } if (i.type && i.type == "submit") { sub = i; } } image_url.value = dataURL; sub.click(); src = null; } catch (ex) { } } }, true); if (!inBg) { getBrowser().selectedTab = tab; } }, searchByImageMenuPopup: function(e) { var searchByImageMenu = this.searchByImageMenu; searchByImageMenu.hidden = !gContextMenu.onImage; var src = gContextMenu.mediaURL || gContextMenu.imageURL || gContextMenu.bgImageURL; if (!src || !(/^((ht|f)tps?:\/\/|data:image|file:)/.test(src))) { searchByImageMenu.hidden = true; return; } //var popup = document.getElementById("contextSearchMiniByBunda1-context-image-search-popup"); var popup = searchByImageMenu.popup; var items; if (!popup.items) { var itemsObj = popup.getElementsByTagName("menuitem"); popup.items = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.getAttribute("label") != "Google") popup.items.push(elem); }); items = popup.items; } else { items = popup.items; } if (/^(data:image|file:)/.test(src)) { items.forEach(function(elem) { elem.setAttribute("disabled", "true"); }); } else { items.forEach(function(elem) { elem.removeAttribute("disabled"); }); } searchByImageMenu.imageSrc = src; }, createSearchByImageMenu: function() { var menu = document.createElement("menu"); var insertMenu = document.getElementById("context-sep-copyimage"); insertMenu.parentNode.insertBefore(menu, insertMenu); this.searchByImageMenu = menu; menu.setAttribute("id", this.nodeIds.searchByImageMenu); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("label", _localize("searchByImage")); menu.setAttribute("image", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAElSURBVDiNY/z//z8DJYCRkIKsthv/kRX9Z2BgmFalARdiIcaGKZXqcH5O+01U+ay2G3MYGBiSiXUmmofnsBDSjEUTMkiBe2Eq1JnZ7TcZBHhZGNythBl0lLkZODmYGX7++sdw/sZnhl3H3zF8+voHwwsYFkR5ijNICLMzTF31hOHnr38MHGxMDJlhMgwv3vxkWL7jJYpaJmzu0lTigWtmYGBg+PHrH8P0VU8YtJV5MNRiNYCfmxmuGQZ+/PrHwMmOqRyrAX///WfgYEOV4mBjwjAUpwHHL31iyA6XgRvCwcbEkBUmw3DuxmcMtVgDkYONicHLVoTBSJOXgYONieHHz38Ml+98Ydh88DXDtx//CBtACmBiYGCYS4H+OYyU5kasgUgKAADN8WLFzlj9rgAAAABJRU5ErkJggg=="); this.searchByImageMenu.popup = menu.appendChild(document.createElementNS(XULNS, "menupopup")); var popup = this.searchByImageMenu.popup; popup.setAttribute("id", this.nodeIds.searchByImageMenuPopup); popup.googleURL = "https://www.google.com/searchbyimage"; var namesList = []; if (options.searchByImage.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.com/searchbyimage?image_url=", "data:image/x-icon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAA9IVCSvSFQuf0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULk9IVCSvSFQub0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQuf0hUL/9IVC//SFQv/0hUL/9Y1O//rIq//+7+f//eXX//vUvf/7z7X/96Fu//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vYwv/97OH/9ZRZ//SFQv/0hUL/9IhG//zbx//3om7/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97uX/+buW//SFQv/0hUL/9IVC//SFQv/5upT/+9O6//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+b6b//zezP/0iEf/9IVC//SFQv/1klf//ezh//vPtP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/3qXr/+siq//m8lv/5wqD//vTu//3t4//1klb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0h0b//vbx//zi0//1j1H/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2nmn/+bmS/////v/4sIX/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5uJH///v5//eoef/1jU//+82y//afav/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vXw//vOs//0hUL/9IVC//ekcf/96+D/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//728v/4sIX/9IVC//SFQv/4s4n///v4//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/6yKn/+byX//SFQv/0hkT//eTV//vWv//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IZE//m6lP/5u5b//OHQ///+/f/6y6//96d3//SFQv/0hUL/9IVC//SFQv/0hULm9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULm9IVCSfSFQub0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//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+buV//vSuf/++PT//OPT//aYYP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2l13///r3/////////fv/+b2Z//SIRv/0hUL/9IVC//SFQv/0hUL/9IVC//WNT//84M///vXv//aZYf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vPtP////////////i0i//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//WQUv///Pr//OPU//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//eTV///////+9O7/9IVD//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//3m2P//////9ppi//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/718H///////3s4f/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vDn///////4soj/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//erff////////38//WTWP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//iziv////////////iwhf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//rMsP///////eXW//WSVv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/4sYb///z7/////////Pv/9ZFV//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ixhv/+8Of//vn1//rMsP/4rH//9plh//WQUv/1j1L/+s2x//////////////////m9mf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SGQ//2nmn/+buW//vNsv/82sb//e3j/////////////////////v/5wZ//9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/83Mj////////////++fb/+K+C//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9ZRZ/////////////vTt//aaYv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/1lFr////////////6xqf/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ehbf/70bj//end//3o2////v3///////3l1//0iEb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5wqD////////////96t7/96Z2//WOUP/2nWf//NvH//zcyP/1i0z/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/96l6/////////////vLr//WPUf/0hUL/9IVC//SFQv/0h0b//end//3k1f/0iUn/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/8387////////////4sYf/9IVC//SFQv/0hUL/9IVC//SFQv/6w6L///////nBn//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC///69////////vj1//SIR//0hUL/9IVC//SFQv/0hUL/9IVC//m+mv///////e3j//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL///r3///////8387/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+syw///////++fb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/95NX///////vUvP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97OH///////7y6//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//i2jv///////N/O//SFQv/0hUL/9IVC//SFQv/0hUL/96Nx////////////+s2x//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IdF//zh0P//+/j/9ZJW//SFQv/0hUL/9IVC//SKSv/96t7///////738v/1k1f/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SF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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAB" ], [ "Yandex", "http://images.yandex.ru/yandsearch?rpt=imagedups&text=&img_url=", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAkdx+AJHc5wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3JYArvIAAK7yAACu8gAArvIAA5Pd5wCr8P8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8CnOT/A5PdewCu8gAArvIAAK7yAAeV3/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/Aa3x/weW4P8Hld8PALDzAACw8wAMmOH///////////////////////////////////////////////////////////8GpOr/DJjhigCy9AAAsvQAEZzk//////8VpOn/Fbr1/xW69f+c4fv/ddb5/xW69f8VuvX/Fbr1/x2o6v//////AbT0/w+f5v8RnOQ8ALX1ABeg5v//////F6bp/xe48/8XuPP/hdf3/4XX9/80wPT/F7jz/xe48/8dqOr//////wC49v8IsPD/F6DmpQC49gAepOn//////wOe6P8DrvD/A67w/1/G8/9fxvP/TsLy/wSu8P8DrvD/CaHo//////8Au/j/ALv4/xep7f8epOlmJKjs//////9GvfD/ft78/37e/P///////////+f5/v+A3/z/ft78/03A8P//////AL75/wC++f8Huvf/JKjszyut7///////OLvw/2Pa/P9j2vz///////////+R5f3/Y9r8/2Pa/P8/vvD//////wDC+v8Awvr/CL74/yut788xsfL//////ya48P9F1fz/RdX8///////N8/7/RdX8/0XV/P9F1fz/Lrnw//////8Axfv/AMX7/yW29P8xsfJmOLX1//////8XtfD/KNH8/yjR/P/8/v//UNr9/yjR/P8o0fz/KNH8/x+48P//////AMn8/xTC+v84tfWlAMn8AD659///////ALHw/wCx8P8AsfD/Gbjw/wCx8P8AsfD/ALHw/wCx8P8JtPD//////wPM/v83u/j/Prn3PADN/gBDvfr///////////////////////////////////////////////////////////8lxvz/Q736igTR/gAE0f4ASMD8/xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8Y0///R8D8/0jA/A8S1f8AEtX/AEzD/uRa2f//XNz//1zc//9c3P//XNz//1zc//9c3P//XNz//1zc//9c3P//Ucv+/0zD/nhc3P8AXNz/AFzc/wBPxf97T8X/5E/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F/5Zc3P8AXNz/AFzc/wBc3P8AAA8AAAAHAAAAAwAAAAMAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAMAAAADAAAABwAAAA8AAA==" ], [ "TinEye", "http://www.tineye.com/search/?pluginver=firefox-1.0&url=", "data:image/x-icon;base64,AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAACxeDVItHk157iAO//WtW7/482G/+XOhv/lzYL/1L98/5mTcf8UKUP/CwsM/xwcG/8AAAD/AAAA/wAAAOcAAA5ItHo25LV7Nv+1ezb/tXs2/8GPSf/EoGj/s5hw/6KPdf93bWT/ZFdK/2daTP9hVEj/XU9C/zIpH/8EAgH/AAAA5LV7Nv+1ezb/tXs2/7V7Nv+1ezb/uIA+/8eea//Wtof/48eU/+PKkv/iyJP/4MeV/9u/kf/HqHz/rI1p/3tmT/+1ezb/tXs2/7V7Nv+1ezb/zKV0/+PKlP/hxXr/zbFk/8esYf/VuW7/3sFz/+LFdf/gw3P/48Z3/+nPjv/dwJD/tXs2/7V7Nv+1ezb/y6Nx/9/Gg/+NekT/V0wv/5uSfP95cmH/JiES/zAqGv86Mh3/W08v/3lpQP+Wg03/zLFn/7V7Nv+1ezb/uoVH/8myg/+VgUr/AAAA/2xpZf/i4+X/+fn5/0JAO/8AAAD/LCkl/768uf+/vr3/Mi8q/x0ZEP+2fDf/tXs2/6WGX/+pklP/JyES/0dFQP96eHX/W1tc//////9ua2X/DAoH/6Wim/+EhIX//////6ejnP8AAAD/wo1F/8GLQ//Conf/tZ1e/wYDAP9pZmH/6+vs/9/f3/////3/Pjoz/zo2Lf/Jycb/UlJT//////+xraX/AAAA/8OORv/Djkb/1bF+/821cf83MSD/MC4s//n49P//////l5OJ/wMCAP9IRDr/////////////////ZGBW/wAAAP/Djkb/w45G/8qkcP+sllr/wKtw/zw5Mf9MSUb/VlNM/wIBAP8AAAD/FxUP/9PQyv/8+/j/rKig/wkHA/8AAAD/w45G/8OORv+1jlj/l4hm/8etZv/QuHf/m4xk/21hSP9PRjX/Mi0j/xsYFf87NzD/VFBK/xUVFf8FBwz/CQsQ/8OORv/Djkb/g2I1/8Oea//Mt4z/uJxU/56hhv92nLj/l6ut/56poP+gpJL/mJeC/5aMbP+bjmv/m49t/52Qbv/Djkb/uItP/05PUP+zjlv/yptc/9C3jP9gYFP/ABVH/wAzc/8IP4T/FUuM/xhSmP99lZ3/5sRv/9S6cf/Lsmr/w45G/1B7rv8bbdT/LWy5/8OORv/Djkf/yqRw/zswIP8AAAD/AAAA/wAAAP8AAAD/Fyk8/5CKZ/+ahU3/modW/8GNReeEj5r/L37g/0Jxqf/Cjkf/w45G/8OORv/Fllb/clYw/zoqFf8hGQ3/IhwU/x4ZFf9HRUD/vaJ5/86pdee+ikU/woxEyZ6HZ/+8jEz/w45G/8OORv/Djkb/w45G/8OORv/Djkb/v4tF/8ORTf/GlFD/xJBJ/8KMRMm+ikU/gAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAE=" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchByImage.addCustomNames && Array.isArray(options.searchByImage.customNamesList)) { namesList = namesList.concat(options.searchByImage.customNamesList); } function itemCreate(name, link, image) { var item = document.createElementNS(XULNS, "menuitem"); item.setAttribute("class", "menuitem-iconic"); item.setAttribute("src", image); item.setAttribute("label", name); item.link = link; popup.appendChild(item); } namesList.forEach(function(elem) { itemCreate(elem[0], elem[1], elem[2]); }); var contextMenu = this.contextMenu; popup.gObj = this; popup.setAttribute("oncommand", "this.gObj.searchByImageCommandHandler(event);"); popup.setAttribute("onclick", "checkForMiddleClick(this, event);"); } } contextSearcherObj.init(); })();
Отсутствует
2k1dmg
Я в полнейшем восторге Спасибо!
upd: что-то "на лету" в контекстном меню не меняется поисковик по умолчанию (если изменять выбор в панели поиска), а только после перезагрузки браузера.
На всякий случай: использую hideDefaultEngineInPopupSubMenu: true, но pinnedEngineName: "" не трогаю.
p.s. если не сильно понятно расписал, могу потом показать с картинками.
Отредактировано Northtech (09-10-2013 21:07:00)
Отсутствует
2k1dmg
Крутой код получился, пора переименовать в Context Search full
Кстати это:
let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); os.addObserver(this, "browser-search-engine-modified", false);
можно проще сделать:
Добавлено 09-10-2013 23:24:06
И попробуй в кнопке:
без:
let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; let XHTMLNS = "http://www.w3.org/1999/xhtml"
Отредактировано bunda1 (09-10-2013 23:30:00)
Отсутствует
Northtech
(function () { // Context Search mini 2013-10-10 var options = { loadInBackground: false, // true - открывать вкладки в фоне pinnedEngineName: "", // оставить пустым если не нужно закреплять // определенный поисковик // примеры pinnedEngineName: "Google" или pinnedEngineName: "Яндекс" или pinnedEngineName: "" hideDefaultEngineInPopupSubMenu: false, // true - не добавлять поисковик по умолчанию в выпадающий список (подменю) поисковиков campactMenu: true, // true - поисковики в выпадающем списке (подменю) без назаваний campactMenuLengthPerLine: 5, // максимальное количество элементов в одной строке // от 3 до 10, по умолчанию 5 searchBySite: { enable: true, // true - добавить поисковики по сайту iconsOn: true, // true - добавить иконки для поисковиков по сайту useDefaultNamesList: true, // true - использовать список поисковиков по умолчанию addCustomNames: false, // true - добавить свои поисковики по сайту customNamesList: [ ["Rambler", ["Rambler", "Рамблер"]] ] // например ["Rambler", ["Rambler", "Рамблер"]] // первая ячека название на английском // вторая ячека массив с предполагаемыми именами поисковика // может состоять из нескольких значений // ["Name1", ["Name1"]], // ["Name2", ["Name2", "Имя2"]], // ["Name3", ["Name3", "Имя3", "Név3"]] }, searchImageByText: { enable: true, // true - добавить поиск изображения по тексту useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] }, searchByImage: { enable: true, // true - добавить поиск по изображению useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] }, searchInCache: { enable: true, // true - добавить поиск в кэше // нужно доработать useDefaultNamesList: true, addCustomNames: false, customNamesList: [ [ "name", "link", "image" ] ] } }; function _localize(sid) { let strings = { en: { searchBySite: "Search this site", searchImageByText: "Search image by text", searchByImage: "Search by image", searchInCache: "Search this page in cache" }, ru: { searchBySite: "Поиск по этому сайту", searchImageByText: "Поиск изображения по тексту", searchByImage: "Поиск по изображению", searchInCache: "Поиск этой страницы в кэше" } }; //let locale = (Application.prefs.getValue("general.useragent.locale", false) || "en").match(/^[a-z]*/)[0]; function getBrowserUILocale() { // Browser UI locale return Components.classes["@mozilla.org/chrome/chrome-registry;1"] .getService(Components.interfaces.nsIXULChromeRegistry) .getSelectedLocale("global"); } let locale = ""; // ru, en if (!locale || locale == "") locale = getBrowserUILocale().match(/^[a-z]*/)[0]; _localize = function (sid) { return strings[locale] && strings[locale][sid] || strings.en[sid] || sid; }; return _localize.apply(this, arguments); } let XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; let XHTMLNS = "http://www.w3.org/1999/xhtml" var contextSearcherObj = { initialized: false, init: function() { if(this.initialized) return; this.initialized = true; this.nodeIds = { searchMenu: "contextSearchMiniByBunda1-menu", searchMenuPopup: "contextSearchMiniByBunda1-popup", searchByImageMenu: "contextSearchMiniByBunda1-image-search-menu", searchByImageMenuPopup: "contextSearchMiniByBunda1-image-search-popup" }; if (document.getElementById(this.nodeIds.searchMenu)) return; var searchService = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); var contextMenu = document.getElementById("contentAreaContextMenu"); var searchSelect = document.getElementById("context-searchselect"); searchSelect.style.display = "none"; var searchMenu = contextMenu.insertBefore(document.createElementNS(XULNS, "menu"), searchSelect); this.searchService = searchService; this.contextMenu = contextMenu; this.searchSelect = searchSelect; this.searchMenu = searchMenu; this.param = { isPinnedEngine: false, pinnedEngineName: "" }; try { this.createSearchMenu(); if (options.searchByImage.enable) this.createSearchByImageMenu(); } catch (ex) { this.destroy(); Components.utils.reportError(ex); return; } if (options.campactMenu) this.loadStyles(); var observeStatus = new MutationObserver(function () { searchMenu.hidden = searchSelect.hidden; }); observeStatus.observe(searchSelect, { attributes: true, attributeFilter: ["hidden"] }); /*var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); this.branch = prefService.getBranch("browser.search."); if (!("addObserver" in this.branch)) this.branch.QueryInterface(Components.interfaces.nsIPrefBranch2); this.branch.addObserver("", this, false);*/ /* var searchPref = "browser.search."; gPrefService.addObserver(searchPref, this, false);*/ /*let os = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); os.addObserver(this, "browser-search-engine-modified", false);*/ Services.obs.addObserver(this, "browser-search-engine-modified", false); Services.ww.registerNotification(this); addEventListener("popupshowing", this, false, contextMenu); addDestructor(function (reason) { observeStatus.disconnect(); Services.ww.unregisterNotification(this); //this.branch.removeObserver("", this); //gPrefService.removeObserver(searchPref, this, false); //os.removeObserver(this, "browser-search-engine-modified", false); Services.obs.removeObserver(this, "browser-search-engine-modified", false); this.destroy(); if (reason != "destructor") this.unloadStyles(); }, this); }, destroy: function() { if(!this.initialized) return; this.initialized = false; var contextMenu = this.contextMenu; if (!contextMenu) return; if (this.searchMenu) contextMenu.removeChild(this.searchMenu); if (this.searchByImageMenu) contextMenu.removeChild(this.searchByImageMenu); if (this.searchSelect) this.searchSelect.style.removeProperty("display"); }, update: function() { this.searchMenu.textContent = ""; this.createSearchMenu(); delete this.updateTimeoutID; }, get isSeaMonkey() { delete this.isSeaMonkey; return this.isSeaMonkey = Services.appinfo.name == "SeaMonkey"; }, observe: function(subject, topic, data) { switch (topic) { case "domwindowclosed": if (subject.document.documentElement.getAttribute("windowtype") == "Browser:SearchManager") { this.update(); } break; /*case "nsPref:changed": switch (data) { case "defaultenginename": case "browser.search.defaultenginename": this.update(); break; } break;*/ case "browser-search-engine-modified": /*switch (data) { case "engine-default": case "engine-current": // engine-default case "engine-changed": case "engine-removed":*/ if (typeof this.updateTimeoutID == "number") { window.clearTimeout(this.updateTimeoutID); delete this.updateTimeoutID; } let _this = this; this.updateTimeoutID = window.setTimeout(function () { _this.update(); }, 1000); /*break; }*/ break; } }, handleEvent: function(e) { //var contextMenu = this.contextMenu; //var menu = this.menu; //var imageMenu = this.imageMenu; switch (e.type) { case "popupshowing": this.popupshowingEvent(e); break; } }, popupshowingEvent: function(e) { var trgId = e.target.id; if (trgId) { if (trgId == "contentAreaContextMenu") { this.contextMenuPopup(e); if (this.searchByImageMenu) this.searchByImageMenuPopup(e); } else if (trgId == this.nodeIds.searchMenuPopup) this.searchMenuPopup(e); } }, _stylesLoaded: false, loadStyles: function() { if(this._stylesLoaded) return; this._stylesLoaded = true; var sss = this.sss; var cssURI = this.cssURI = this.makeCSSURI(); if(!sss.sheetRegistered(cssURI, sss.USER_SHEET)) sss.loadAndRegisterSheet(cssURI, sss.USER_SHEET); }, unloadStyles: function() { if(!this._stylesLoaded) return; this._stylesLoaded = false; var sss = this.sss; if(sss.sheetRegistered(this.cssURI, sss.USER_SHEET)) sss.unregisterSheet(this.cssURI, sss.USER_SHEET); }, get sss() { delete this.sss; return this.sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService); }, makeCSSURI: function() { var cssStr = '\ @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");\n\ @-moz-document url("' + window.location.href + '") {\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] {\n\ /*width: 2em !important;*/\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] * {\n\ /*padding-left: 0 !important;\n\ padding-right: 0 !important;\n\ margin-left: 0 !important;\n\ margin-right: 0 !important;*/\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > spacer[campactMenu="true"] {\n\ width: 2em !important;\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox > .menuitem-iconic[campactMenu="true"] {\n\ width: 3em !important;\n\ height: 2em !important;\n\ }\n\ #' + this.nodeIds.searchMenuPopup + ' > hbox >.menuitem-iconic[campactMenu="true"] > image {\n\ margin-left: .8em !important;\n\ }\n\ }\n\ '; return Services.io.newURI("data:text/css," + encodeURIComponent(cssStr), null, null); }, searchCommandHandler: function(event, trg) { var inBg = options.loadInBackground || false; if (event.type == "click" && event.button && event.button == 1) { inBg = !inBg; } var searchBySite = ""; if (event.target.hasAttribute("searchBySite")) { searchBySite = " site:" + gBrowser.currentURI.host; } else if (event.target.hasAttribute("searchInCache")) { searchBySite = content.location.href; } let selectedText = this.isSeaMonkey ? content.getSelection().toString() : getBrowserSelection(); if (event.target.engine.imageLink) { gBrowser.loadOneTab(event.target.engine.imageLink + /*getBrowserSelection()*/ selectedText, { relatedToCurrent: true, inBackground: inBg }); } else if (event.target.engine.cacheLink) { gBrowser.loadOneTab(event.target.engine.cacheLink + /*getBrowserSelection()*/ searchBySite, { relatedToCurrent: true, inBackground: inBg }); } else { let submission = event.target.engine.getSubmission(/*getBrowserSelection()*/ selectedText + searchBySite, null); gBrowser.loadOneTab(submission.uri.spec, { relatedToCurrent: true, postData: submission.postData, inBackground: inBg }); } if (trg == "menu") { setTimeout(function () { document.getElementById("contentAreaContextMenu").hidePopup(); }, 0); } }, contextMenuPopup: function(e) { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.searchMenu; //var selectedText = getBrowserSelection(16); var selectedText = this.isSeaMonkey ? content.getSelection(16).toString() : getBrowserSelection(16); if (!selectedText) return; var ellipsis = "\u2026"; try { ellipsis = gPrefService.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; } catch (ex) { } if (selectedText.length > 15) selectedText = selectedText.substr(0,15) + ellipsis; let rEngine = this.isSeaMonkey ? "currentEngine" : "defaultEngine"; var engineName = this.param.isPinnedEngine ? this.param.pinnedEngineName : searchService[rEngine].name; var menuLabel; var searchFormattedString = [ "contextMenuSearch", "contextMenuSearchText", "searchSelected" ]; var thisIsSM = this.isSeaMonkey; function getMenuLabel(str) { try { if (thisIsSM) { let bundle = document.getElementById("contentAreaCommandsBundle"); return bundle.getFormattedString(str, [engineName, selectedText]); } else return gNavigatorBundle.getFormattedString(str, [engineName, selectedText]); } catch (ex) { return false; } } for(let i in searchFormattedString) { menuLabel = getMenuLabel(searchFormattedString[i]); if (menuLabel) break; else if (!menuLabel && i == searchFormattedString.length-1) menuLabel = engineName; } menu.label = menuLabel; }, searchMenuPopup: function(e) { var popup = e.target; var items; if (!popup.items) { var itemsObj = popup.getElementsByTagName("menuitem"); popup.items = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) popup.items.push(elem); }); items = popup.items; } else { items = popup.items; } var menus; if (!popup.menus) { var itemsObj = popup.getElementsByTagName("menu"); popup.menus = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menu" && elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) popup.menus.push(elem); }); menus = popup.menus; } else { menus = popup.menus; } var siteSearchDomain; var gBrowser = gBrowser || getBrowser(); function isDomain() { try { siteSearchDomain = gBrowser.currentURI.host; } catch (ex) { return false; } return true; } if (isDomain()) { items.forEach(function(elem) { //if (elem.hasAttribute("searchBySite")) // elem.setAttribute("tooltiptext", siteSearchDomain); elem.removeAttribute("disabled"); }); menus.forEach(function(elem) { if (elem.hasAttribute("searchBySite")) elem.setAttribute("tooltiptext", siteSearchDomain); else if (elem.hasAttribute("searchInCache")) elem.setAttribute("tooltiptext", content.document.title); elem.removeAttribute("disabled"); }); } else { items.forEach(function(elem) { //if (elem.hasAttribute("searchBySite")) // elem.removeAttribute("tooltiptext"); elem.setAttribute("disabled", "true"); }); menus.forEach(function(elem) { if (elem.hasAttribute("searchBySite") || elem.hasAttribute("searchInCache")) elem.removeAttribute("tooltiptext"); elem.setAttribute("disabled", "true"); }); } }, createSearchMenu: function() { var searchService = this.searchService; var contextMenu = this.contextMenu; var menu = this.searchMenu; var engines = searchService.getVisibleEngines({}); menu.setAttribute("id", this.nodeIds.searchMenu); menu.setAttribute("class", "menu-iconic"); this.param.isPinnedEngine = false; this.param.pinnedEngineName = ""; var pinnedEngineName = options.pinnedEngineName; if (pinnedEngineName != "") { for (let i in engines) { if (engines[i].name != pinnedEngineName) continue; menu.setAttribute("label", engines[i].name); menu.setAttribute("image", engines[i].iconURI.spec); menu.engine = engines[i]; this.param.isPinnedEngine = true; this.param.pinnedEngineName = pinnedEngineName; break; } } let rEngine = this.isSeaMonkey ? "currentEngine" : "defaultEngine"; if (!this.param.isPinnedEngine) { menu.setAttribute("label", searchService[rEngine].name); menu.setAttribute("image", searchService[rEngine].iconURI.spec); menu.engine = searchService[rEngine]; } menu.gObj = this; menu.setAttribute("onclick", "if (event.target == this && event.target.engine) this.gObj.searchCommandHandler(event, 'menu');"); menu.popup = menu.appendChild(document.createElementNS(XULNS, "menupopup")); var popup = this.searchMenu.popup; popup.setAttribute("id", this.nodeIds.searchMenuPopup); var counterMaxLength = options.campactMenuLengthPerLine; if (typeof counterMaxLength != "number" || 3 > counterMaxLength || counterMaxLength > 10) counterMaxLength = 5; var counter = 0; var hBox; function itemCreateCampact(engine, last) { if(counter == 0) { hBox = document.createElementNS(XULNS, "hbox"); let item = document.createElementNS(XULNS, "spacer"); //item.setAttribute("style", "width: 2em"); item.setAttribute("campactMenu", "true"); hBox.appendChild(item); } counter++; var item = document.createElementNS(XULNS, "menuitem"); item.engine = engine; item.setAttribute("class", "menuitem-iconic"); item.setAttribute("tooltiptext", engine.name); //item.setAttribute("src", engine.iconURI.spec); var image = document.createElementNS(XULNS, "image"); image.setAttribute("src", engine.iconURI.spec); item.appendChild(image); //item.setAttribute("style", "max-width: 2em"); item.setAttribute("campactMenu", "true"); hBox.appendChild(item); if (counter == counterMaxLength || last) { popup.appendChild(hBox); counter = 0; } } var separator = {}; function itemCreate(engine, reason) { var item = document.createElementNS(XULNS, "menuitem"); item.setAttribute("class", "menuitem-iconic"); item.engine = engine; if (reason && !separator[reason]) { /*let sep = separator[reason] = document.createElementNS(XULNS, "menuseparator"); sep.setAttribute(reason, "true"); popup.appendChild(sep); let item = document.createElementNS(XULNS, "label"); //item.setAttribute("class", "menuitem-iconic"); item.setAttribute("value", _localize(reason) + ":"); item.setAttribute("style", "padding-left: 2em"); popup.appendChild(item);*/ if (!separator["menuseparator"]) { let sep = separator["menuseparator"] = document.createElementNS(XULNS, "menuseparator"); popup.appendChild(sep); } let subMenu = separator[reason] = document.createElementNS(XULNS, "menu"); subMenu.setAttribute("class", "menu-iconic"); subMenu.setAttribute("label", _localize(reason)); subMenu.setAttribute(reason, "true"); subMenu.popup = subMenu.appendChild(document.createElementNS(XULNS, "menupopup")); popup.appendChild(subMenu); } if (reason == "searchBySite") { item.setAttribute("label", engine.name); if (options.searchBySite.iconsOn) { item.setAttribute("src", engine.iconURI.spec); } item.setAttribute(reason, "true"); } else if (reason == "searchImageByText" || reason == "searchInCache") { item.setAttribute("label", engine.name); item.setAttribute("src", engine.iconURI_spec); item.setAttribute(reason, "true"); } else { item.setAttribute("label", engine.name); item.setAttribute("src", engine.iconURI.spec); } //popup.appendChild(item); if (reason) { let subMenu = separator[reason]; subMenu.popup.appendChild(item); } else popup.appendChild(item); } for (let i in engines) { if (options.hideDefaultEngineInPopupSubMenu && this.param.isPinnedEngine && engines[i].name == pinnedEngineName || options.hideDefaultEngineInPopupSubMenu && !this.param.isPinnedEngine && engines[i].name == searchService[rEngine].name) { continue; } if (options.campactMenu) itemCreateCampact(engines[i], i == engines.length-1); else itemCreate(engines[i]); } function searchBySite_itemCreate() { var namesList = []; if (options.searchBySite.useDefaultNamesList) { let defaultNamesList = [ ["Google", ["Google"]], ["Yandex", ["Yandex", "Яндекс"]], ["Yahoo", ["Yahoo"]], ["Bing", ["Bing"]], ["DuckDuckGo", ["DuckDuckGo"]] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchBySite.addCustomNames && Array.isArray(options.searchBySite.customNamesList)) { namesList = namesList.concat(options.searchBySite.customNamesList); } //let i_skips = []; function isNameExist(names, engine) { for (let i in names) { if (names[i] != engine && i != names.length-1) continue; else if (names[i] == engine) return true; return false; } } namesList.forEach(function(elem) { for (let i in engines) { if (/*i_skips.indexOf(i) != -1 ||*/ !(elem[1].some(function(listName) listName == engines[i].name)) /*!isNameExist(elem[1], engines[i].name)*/ /*elem[1].indexOf(engines[i].name) == -1*/) continue; itemCreate(engines[i], "searchBySite"); //i_skips.push(i); break; } }); } if (options.searchBySite.enable) { searchBySite_itemCreate(); } function searchImageByText_itemCreate() { var namesList = []; if (options.searchImageByText.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.ru/search?tbm=isch&q=", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB41BMVEUAAAB7wUJ6wUJ6wUJ6wUL1nxn1oBn1oBn1nxl6wUJ6wUJ6wUJrvUT1mxr1nxn1nxlfu0Z8wkLznhv0mhp6wUJWuUdaukfLrSv4rhX1nxl5wUJyv0TQrCnyjhz1kyH2pRj1oBl7wkNbukfzjR3zkxv1liHuMDXuGTf2rxN7wUJeu0apuDfzjhz1nBvuNizwZi/3sxP2pBh9wkGvuTbvoRvuJy/xcC33qRhbl7F2uGOMwT94havnRTzuMjjwTTNRislRjcZ5uVpnvU0rk9Fhjr3aTkPuL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 "Yandex", "http://images.yandex.ru/yandsearch?text=", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAkdx+AJHc5wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3JYArvIAAK7yAACu8gAArvIAA5Pd5wCr8P8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8CnOT/A5PdewCu8gAArvIAAK7yAAeV3/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/Aa3x/weW4P8Hld8PALDzAACw8wAMmOH///////////////////////////////////////////////////////////8GpOr/DJjhigCy9AAAsvQAEZzk//////8VpOn/Fbr1/xW69f+c4fv/ddb5/xW69f8VuvX/Fbr1/x2o6v//////AbT0/w+f5v8RnOQ8ALX1ABeg5v//////F6bp/xe48/8XuPP/hdf3/4XX9/80wPT/F7jz/xe48/8dqOr//////wC49v8IsPD/F6DmpQC49gAepOn//////wOe6P8DrvD/A67w/1/G8/9fxvP/TsLy/wSu8P8DrvD/CaHo//////8Au/j/ALv4/xep7f8epOlmJKjs//////9GvfD/ft78/37e/P///////////+f5/v+A3/z/ft78/03A8P//////AL75/wC++f8Huvf/JKjszyut7///////OLvw/2Pa/P9j2vz///////////+R5f3/Y9r8/2Pa/P8/vvD//////wDC+v8Awvr/CL74/yut788xsfL//////ya48P9F1fz/RdX8///////N8/7/RdX8/0XV/P9F1fz/Lrnw//////8Axfv/AMX7/yW29P8xsfJmOLX1//////8XtfD/KNH8/yjR/P/8/v//UNr9/yjR/P8o0fz/KNH8/x+48P//////AMn8/xTC+v84tfWlAMn8AD659///////ALHw/wCx8P8AsfD/Gbjw/wCx8P8AsfD/ALHw/wCx8P8JtPD//////wPM/v83u/j/Prn3PADN/gBDvfr///////////////////////////////////////////////////////////8lxvz/Q736igTR/gAE0f4ASMD8/xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8Y0///R8D8/0jA/A8S1f8AEtX/AEzD/uRa2f//XNz//1zc//9c3P//XNz//1zc//9c3P//XNz//1zc//9c3P//Ucv+/0zD/nhc3P8AXNz/AFzc/wBPxf97T8X/5E/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F/5Zc3P8AXNz/AFzc/wBc3P8AAA8AAAAHAAAAAwAAAAMAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAMAAAADAAAABwAAAA8AAA==" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchImageByText.addCustomNames && Array.isArray(options.searchImageByText.customNamesList)) { namesList = namesList.concat(options.searchImageByText.customNamesList); } namesList.forEach(function(elem) { let engine = {}; engine.name = elem[0]; engine.imageLink = elem[1]; engine.iconURI_spec = elem[2]; itemCreate(engine, "searchImageByText"); }); } if (options.searchImageByText.enable) { searchImageByText_itemCreate(); } function searchInCache() { var namesList = []; if (options.searchInCache.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.com/search?q=cache:", "data:image/x-icon;base64,AAABAAIAEBAAAAAAAAB9AQAAJgAAACAgAAAAAAAA8gIAAKMBAACJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAFESURBVDjLpZNJSwNBEIXnt4lE4kHxovgT9BDwJHqPy0HEEOJBiAuCRg+KUdC4QS4KrpC4gCBGE3NQ48JsnZ6eZ3UOM6gjaePhQU93v6+qq2q0pqgeJj2S8EdJT1hr0OxBtKCD5iEd8QxDYpvhvOBAuMDKURX9C9aPu4GA1GEVkzvMg10UBfYveWAWgYAP00V01fa+R9M2bA51wJvhIn3qR+ybt3D3JNQBE5sMjCIOLFpoHzOwdsLRO22qA6R6kiZiWwxUvy/PUQZIhYZ1vFM9cvcOOsYNdcBgysISdSJBnZjJMlR0Fw8vAp0xoz5gao/h+NZBy4i/10XGwrPA+hmvD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0pKSv9NTU3/TExM/0xMTP9LS0v/TExM/01NTf9NTU3/TU1N/01NTf9NTU3/TU1N/01NTf9NTU3/TU1N/0xMTP9NTU3/TU1N/0xMTP9MTEz/SkpK/01NTf8SEhL/AAAA/wICAv8CAgL/BAQE/wEBAf8BAQH/AQEB/wAAAP8NDQ3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3l5ef8BAQH/BgYG/wAAAP8CAgL/AQEB/wEBAf8DAwP/AAAA/wMDA/8oKCj/LS0t/zExMf8tLS3/Kioq/ysrK/8sLCz/Ly8v/zAwMP8qKir/LCws/yoqKv8oKCj/LCws/zAwMP8rKyv/KSkp/ykpKf8qKir/MDAw/y8vL/8rKyv/ERER/wAAAP8BAQH/AgIC/wICAv8BAQH/AAAA/wEBAf8CAgL/AAAA/wUFBf+rq6v/7Ozs/3V1df8AAAD/AAAA/zs7O//j4+P/4uLi/zo6Ov8AAAD/AAAA/wQEBP+rq6v/7Ozs/4WFhf8AAAD/AAAA/zw8PP/k5OT/4+Pj/zk5Of8AAAD/BQUF/wAAAP8BAQH/AQEB/wAAAP8BAQH/AAAA/wMDA/8AAAD/ISEh/+Hh4f//////uLi4/wkJCf8CAgL/bW1t////////////bW1t/wICAv8CAgL/ISEh/+Hh4f//////wMDA/woKCv8CAgL/bW1t////////////bW1t/wEBAf8HBwf/AgIC/wEBAf8AAAD/AQEB/wEBAf8AAAD/AwMD/wAAAP8cHBz/2NjY//////+4uLj/BwcH/wAAAP9lZWX//f39//////9nZ2f/AAAA/wAAAP8ZGRn/2dnZ//////+3t7f/CAgI/wAAAP9oaGj//Pz8//7+/v9mZmb/AAAA/wYGBv8AAAD/AgIC/wEBAf8BAQH/AwMD/wICAv8BAQH/AAAA/xsbG//Y2Nj//////7i4uP8GBgb/AAAA/2pqav///////v7+/2VlZf8AAAD/AAAA/xsbG//Y2Nj//////7m5uf8HBwf/AAAA/2VlZf///////////2VlZf8AAAD/BQUF/wEBAf8DAwP/AQEB/wAAAP8AAAD/AAAA/wQEBP8AAAD/HR0d/9ra2v//////urq6/wgICP8AAAD/Z2dn////////////aGho/wAAAP8AAAD/HR0d/9vb2///////urq6/wcHB/8AAAD/aGho////////////aWlp/wAAAP8FBQX/AAAA/wEBAf8BAQH/AAAA/wAAAP8AAAD/AgIC/wAAAP8cHBz/29vb//////+4uLj/BgYG/wAAAP9mZmb///////////9nZ2f/AAAA/wAAAP8aGhr/2tra//////+4uLj/BwcH/wAAAP9lZWX///////////9mZmb/AAAA/wUFBf8AAAD/AAAA/wAAAP8AAAD/AAAA/wEBAf8DAwP/AAAA/xwcHP/a2tr//////7i4uP8GBgb/AAAA/2ZmZv///////////2dnZ/8AAAD/AAAA/xsbG//b29v//////7m5uf8JCQn/AAAA/2hoaP///////////2dnZ/8AAAD/BQUF/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wMDA/8AAAD/Ghoa/9nZ2f//////ubm5/wYGBv8AAAD/ZmZm////////////ZmZm/wAAAP8AAAD/Gxsb/9ra2v//////uLi4/wcHB/8AAAD/ZmZm//7+/v/+/v7/ZmZm/wAAAP8EBAT/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AwMD/wAAAP8aGhr/2NjY//////+6urr/BgYG/wAAAP9mZmb///////////9mZmb/AAAA/wAAAP8aGhr/2NjY//////+5ubn/BwcH/wAAAP9nZ2f//v7+//////9nZ2f/AAAA/wQEBP8AAAD/AAAA/wAAAP8AAAD/AAAA/wEBAf8DAwP/AAAA/xwcHP/a2tr//////7q6uv8HBwf/AAAA/2ZmZv///////////2ZmZv8AAAD/AAAA/xoaGv/Y2Nj//////7i4uP8GBgb/AAAA/2ZmZv/9/f3//v7+/2ZmZv8AAAD/BAQE/wAAAP8AAAD/AAAA/wAAAP8AAAD/AQEB/wMDA/8AAAD/HBwc/9vb2///////urq6/wgICP8AAAD/ZmZm////////////Z2dn/wAAAP8AAAD/Gxsb/9nZ2f//////urq6/wcHB/8AAAD/Z2dn////////////Z2dn/wAAAP8EBAT/AAAA/wAAAP8AAAD/AAAA/wAAAP8CAgL/BAQE/wAAAP8dHR3/29vb//////+8vLz/BwcH/wAAAP9nZ2f///////////9mZmb/AAAA/wAAAP8bGxv/29vb//////+6urr/BgYG/wAAAP9nZ2f///////////9mZmb/AAAA/wYGBv8AAAD/AQEB/wEBAf8AAAD/AQEB/wMDA/8DAwP/AAAA/x0dHf/a2tr/+fn5/7CwsP8GBgb/AAAA/2pqav/5+fn/+fn5/2tra/8AAAD/AAAA/xwcHP/Z2dn/+fn5/7m5uf8JCQn/AAAA/2xsbP/5+fn/+fn5/2tra/8AAAD/BwcH/wEBAf8CAgL/AQEB/wEBAf8CAgL/AwMD/wMDA/8AAAD/FxcX/9zc3P//////l5eX/wcHB/8DAwP/YGBg////////////XFxc/wQEBP8FBQX/GBgY/97e3v//////s7Oz/wkJCf8EBAT/XV1d////////////W1tb/wEBAf8EBAT/AQEB/wMDA/8DAwP/AAAA/wEBAf8DAwP/AQEB/wEBAf8AAAD/LS0t/1RUVP8hISH/AAAA/wAAAP8BAQH/TExM/0tLS/8AAAD/AAAA/wAAAP8AAAD/LS0t/1NTU/8bGxv/AAAA/wAAAP8BAQH/TExM/0tLS/8BAQH/AAAA/wEBAf8AAAD/AQEB/wAAAP8CAgL/AQEB/wEBAf8AAAD/BwcH/8XFxf++vr7/tbW1/729vf/Kysr/y8vL/8fHx/+2trb/tra2/8bGxv/Ly8v/yMjI/8rKyv+7u7v/tbW1/8DAwP/Ly8v/y8vL/8XFxf+1tbX/srKy/8nJyf9PT0//AAAA/wYGBv8CAgL/AAAA/wEBAf8AAAD/AQEB/wEBAf8KCgr//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3Jycv8AAAD/BwcH/wEBAf8DAwP/AQEB/wAAAP8BAQH/AAAA/wgICP95eXn/fX19/319ff9/f3//gICA/4CAgP+BgYH/gICA/39/f/+BgYH/gYGB/4CAgP+AgID/gICA/4GBgf+AgID/gICA/4GBgf9/f3//fX19/3l5ef9+fn7/MjIy/wA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchInCache.addCustomNames && Array.isArray(options.searchInCache.customNamesList)) { namesList = namesList.concat(options.searchInCache.customNamesList); } namesList.forEach(function(elem) { let engine = {}; engine.name = elem[0]; engine.cacheLink = elem[1]; engine.iconURI_spec = elem[2]; itemCreate(engine, "searchInCache"); }); } if (options.searchInCache.enable) { searchInCache(); } popup.gObj = this; //popup.setAttribute("oncommand", "if (!event.target.engine) return; var csObj = this.gObj || document.getElementById('contextSearchMiniByBunda1-context-popup').gObj; csObj.searchCommandHandler(event);"); popup.setAttribute("oncommand", "if (!event.target.engine || event.target.nodeName == 'menu') return; this.gObj.searchCommandHandler(event);"); popup.setAttribute("onclick", "checkForMiddleClick(this, event);"); }, searchByImageCommandHandler: function(event) { var inBg = options.loadInBackground || false; if (event.type == "click" && event.button && event.button == 1) { inBg = !inBg; } var searchByImageMenu = this.searchByImageMenu; var link = event.target.link; var imageLink = searchByImageMenu.imageSrc; if (imageLink.indexOf("data:") == 0) { this.searchByImageByData(imageLink, inBg); return; } else if (imageLink.indexOf("file:") == 0) { this.searchByImageByFile(imageLink, inBg); return; } else { imageLink = encodeURIComponent(imageLink) } var gBrowser = gBrowser || getBrowser(); gBrowser.loadOneTab(link + imageLink, { relatedToCurrent: true, inBackground: inBg }); }, // searchByImageByData() and searchByImageByFile() based on // Google Image Search 0.5 by Nishan Naseer // https://addons.mozilla.org/ru/firefox/addon/google-similar-images searchByImageByData: function(src, inBg) { var gBrowser = gBrowser || getBrowser(); //var tab = gBrowser.addTab(this.searchByImageMenu.popup.googleURL); var tab = gBrowser.loadOneTab(this.searchByImageMenu.popup.googleURL, { relatedToCurrent: true }); var newTabBrowser = gBrowser.getBrowserForTab(tab); newTabBrowser.addEventListener("load", function byData(e) { newTabBrowser.removeEventListener(e.type, byData, true); if (src) { try { var image_url; var sub; var form = newTabBrowser.contentDocument.getElementById("qbf"); var inputs = form.getElementsByTagName("input"); for (var k = 0; k < inputs.length; k++) { var i = inputs[k]; if (i.name && i.name == "image_url") { image_url = i; } if (i.type && i.type == "submit") { sub = i; } } image_url.value = src; sub.click(); src = null; } catch (ex) { } } }, true); if (!inBg) { getBrowser().selectedTab = tab; } }, searchByImageByFile: function(src, inBg) { //Canvas to get contents in base-64 var canvas = gContextMenu.target.ownerDocument.createElementNS(XHTMLNS, "canvas"); var image = new Image(); image.src = src; canvas.width = image.width; canvas.height = image.height; var ctx = canvas.getContext("2d"); ctx.drawImage(image, 0, 0); var dataURL = canvas.toDataURL("image/png"); var gBrowser = gBrowser || getBrowser(); //var tab = gBrowser.addTab(this.searchByImageMenu.popup.googleURL); var tab = gBrowser.loadOneTab(this.searchByImageMenu.popup.googleURL, { relatedToCurrent: true }); var newTabBrowser = gBrowser.getBrowserForTab(tab); newTabBrowser.addEventListener("load", function byFile(e) { newTabBrowser.removeEventListener(e.type, byFile, true); if (src) { try { var image_url; var sub; var form = newTabBrowser.contentDocument.getElementById("qbf"); var inputs = form.getElementsByTagName("input"); for (var k = 0; k < inputs.length; k++) { var i = inputs[k]; if (i.name && i.name == "image_url") { image_url = i; } if (i.type && i.type == "submit") { sub = i; } } image_url.value = dataURL; sub.click(); src = null; } catch (ex) { } } }, true); if (!inBg) { getBrowser().selectedTab = tab; } }, searchByImageMenuPopup: function(e) { var searchByImageMenu = this.searchByImageMenu; searchByImageMenu.hidden = !gContextMenu.onImage; var src = gContextMenu.mediaURL || gContextMenu.imageURL || gContextMenu.bgImageURL; if (!src || !(/^((ht|f)tps?:\/\/|data:image|file:)/.test(src))) { searchByImageMenu.hidden = true; return; } //var popup = document.getElementById("contextSearchMiniByBunda1-context-image-search-popup"); var popup = searchByImageMenu.popup; var items; if (!popup.items) { var itemsObj = popup.getElementsByTagName("menuitem"); popup.items = []; Array.slice(itemsObj).forEach(function(elem) { if (typeof elem == "object" && elem.nodeName == "menuitem" && elem.getAttribute("label") != "Google") popup.items.push(elem); }); items = popup.items; } else { items = popup.items; } if (/^(data:image|file:)/.test(src)) { items.forEach(function(elem) { elem.setAttribute("disabled", "true"); }); } else { items.forEach(function(elem) { elem.removeAttribute("disabled"); }); } searchByImageMenu.imageSrc = src; }, createSearchByImageMenu: function() { var menu = document.createElement("menu"); var insertMenu = document.getElementById("context-sep-copyimage"); insertMenu.parentNode.insertBefore(menu, insertMenu); this.searchByImageMenu = menu; menu.setAttribute("id", this.nodeIds.searchByImageMenu); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("label", _localize("searchByImage")); menu.setAttribute("image", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAElSURBVDiNY/z//z8DJYCRkIKsthv/kRX9Z2BgmFalARdiIcaGKZXqcH5O+01U+ay2G3MYGBiSiXUmmofnsBDSjEUTMkiBe2Eq1JnZ7TcZBHhZGNythBl0lLkZODmYGX7++sdw/sZnhl3H3zF8+voHwwsYFkR5ijNICLMzTF31hOHnr38MHGxMDJlhMgwv3vxkWL7jJYpaJmzu0lTigWtmYGBg+PHrH8P0VU8YtJV5MNRiNYCfmxmuGQZ+/PrHwMmOqRyrAX///WfgYEOV4mBjwjAUpwHHL31iyA6XgRvCwcbEkBUmw3DuxmcMtVgDkYONicHLVoTBSJOXgYONieHHz38Ml+98Ydh88DXDtx//CBtACmBiYGCYS4H+OYyU5kasgUgKAADN8WLFzlj9rgAAAABJRU5ErkJggg=="); this.searchByImageMenu.popup = menu.appendChild(document.createElementNS(XULNS, "menupopup")); var popup = this.searchByImageMenu.popup; popup.setAttribute("id", this.nodeIds.searchByImageMenuPopup); popup.googleURL = "https://www.google.com/searchbyimage"; var namesList = []; if (options.searchByImage.useDefaultNamesList) { let defaultNamesList = [ [ "Google", "https://www.google.com/searchbyimage?image_url=", "data:image/x-icon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAASCwAAEgsAAAAAAAAAAAAA9IVCSvSFQuf0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULk9IVCSvSFQub0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQuf0hUL/9IVC//SFQv/0hUL/9Y1O//rIq//+7+f//eXX//vUvf/7z7X/96Fu//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vYwv/97OH/9ZRZ//SFQv/0hUL/9IhG//zbx//3om7/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97uX/+buW//SFQv/0hUL/9IVC//SFQv/5upT/+9O6//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+b6b//zezP/0iEf/9IVC//SFQv/1klf//ezh//vPtP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/3qXr/+siq//m8lv/5wqD//vTu//3t4//1klb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0h0b//vbx//zi0//1j1H/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2nmn/+bmS/////v/4sIX/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5uJH///v5//eoef/1jU//+82y//afav/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vXw//vOs//0hUL/9IVC//ekcf/96+D/9IVC//SF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9IVC8fSFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQvP0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9YtL//i2jv/828f//vLr///7+P///Pv//vTu//3n2v/6zbH/96Nw//SFQ//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ekcv/+8+z////////////+9fD/+9K5//m9mf/4to7/+buV//vSuf/++PT//OPT//aYYP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/2l13///r3/////////fv/+b2Z//SIRv/0hUL/9IVC//SFQv/0hUL/9IVC//WNT//84M///vXv//aZYf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vPtP////////////i0i//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//WQUv///Pr//OPU//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//eTV///////+9O7/9IVD//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//3m2P//////9ppi//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/718H///////3s4f/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL//vDn///////4soj/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//erff////////38//WTWP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//iziv////////////iwhf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//rMsP///////eXW//WSVv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/4sYb///z7/////////Pv/9ZFV//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ixhv/+8Of//vn1//rMsP/4rH//9plh//WQUv/1j1L/+s2x//////////////////m9mf/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SGQ//2nmn/+buW//vNsv/82sb//e3j/////////////////////v/5wZ//9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/83Mj////////////++fb/+K+C//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9ZRZ/////////////vTt//aaYv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/1lFr////////////6xqf/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//ehbf/70bj//end//3o2////v3///////3l1//0iEb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/5wqD////////////96t7/96Z2//WOUP/2nWf//NvH//zcyP/1i0z/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/96l6/////////////vLr//WPUf/0hUL/9IVC//SFQv/0h0b//end//3k1f/0iUn/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/8387////////////4sYf/9IVC//SFQv/0hUL/9IVC//SFQv/6w6L///////nBn//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC///69////////vj1//SIR//0hUL/9IVC//SFQv/0hUL/9IVC//m+mv///////e3j//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL///r3///////8387/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/+syw///////++fb/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/95NX///////vUvP/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/97OH///////7y6//0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//i2jv///////N/O//SFQv/0hUL/9IVC//SFQv/0hUL/96Nx////////////+s2x//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IdF//zh0P//+/j/9ZJW//SFQv/0hUL/9IVC//SKSv/96t7///////738v/1k1f/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9YxN//vUvf/96+D/96Z0//WNT//3om///ebY/////////Pv/+LKI//WVW//0h0X/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//agbP/7zbL//enc//749P////////////////////////////3r4P/3p3f/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hULx9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC8/SFQq30hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUKt9IVCJ/SFQu/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC7/SFQif0hUIA9IVCJfSFQq30hULx9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC8fSFQq30hUIl9IVCAIAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAB" ], [ "Yandex", "http://images.yandex.ru/yandsearch?rpt=imagedups&text=&img_url=", "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAkdx+AJHc5wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3P8Akdz/AJHc/wCR3JYArvIAAK7yAACu8gAArvIAA5Pd5wCr8P8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8ArvL/AK7y/wCu8v8CnOT/A5PdewCu8gAArvIAAK7yAAeV3/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/ALDz/wCw8/8AsPP/Aa3x/weW4P8Hld8PALDzAACw8wAMmOH///////////////////////////////////////////////////////////8GpOr/DJjhigCy9AAAsvQAEZzk//////8VpOn/Fbr1/xW69f+c4fv/ddb5/xW69f8VuvX/Fbr1/x2o6v//////AbT0/w+f5v8RnOQ8ALX1ABeg5v//////F6bp/xe48/8XuPP/hdf3/4XX9/80wPT/F7jz/xe48/8dqOr//////wC49v8IsPD/F6DmpQC49gAepOn//////wOe6P8DrvD/A67w/1/G8/9fxvP/TsLy/wSu8P8DrvD/CaHo//////8Au/j/ALv4/xep7f8epOlmJKjs//////9GvfD/ft78/37e/P///////////+f5/v+A3/z/ft78/03A8P//////AL75/wC++f8Huvf/JKjszyut7///////OLvw/2Pa/P9j2vz///////////+R5f3/Y9r8/2Pa/P8/vvD//////wDC+v8Awvr/CL74/yut788xsfL//////ya48P9F1fz/RdX8///////N8/7/RdX8/0XV/P9F1fz/Lrnw//////8Axfv/AMX7/yW29P8xsfJmOLX1//////8XtfD/KNH8/yjR/P/8/v//UNr9/yjR/P8o0fz/KNH8/x+48P//////AMn8/xTC+v84tfWlAMn8AD659///////ALHw/wCx8P8AsfD/Gbjw/wCx8P8AsfD/ALHw/wCx8P8JtPD//////wPM/v83u/j/Prn3PADN/gBDvfr///////////////////////////////////////////////////////////8lxvz/Q736igTR/gAE0f4ASMD8/xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8S1f//EtX//xLV//8Y0///R8D8/0jA/A8S1f8AEtX/AEzD/uRa2f//XNz//1zc//9c3P//XNz//1zc//9c3P//XNz//1zc//9c3P//Ucv+/0zD/nhc3P8AXNz/AFzc/wBPxf97T8X/5E/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F//9Pxf//T8X//0/F/5Zc3P8AXNz/AFzc/wBc3P8AAA8AAAAHAAAAAwAAAAMAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAMAAAADAAAABwAAAA8AAA==" ], [ "TinEye", "http://www.tineye.com/search/?pluginver=firefox-1.0&url=", "data:image/x-icon;base64,AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAACxeDVItHk157iAO//WtW7/482G/+XOhv/lzYL/1L98/5mTcf8UKUP/CwsM/xwcG/8AAAD/AAAA/wAAAOcAAA5ItHo25LV7Nv+1ezb/tXs2/8GPSf/EoGj/s5hw/6KPdf93bWT/ZFdK/2daT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w45G/8OORv/Fllb/clYw/zoqFf8hGQ3/IhwU/x4ZFf9HRUD/vaJ5/86pdee+ikU/woxEyZ6HZ/+8jEz/w45G/8OORv/Djkb/w45G/8OORv/Djkb/v4tF/8ORTf/GlFD/xJBJ/8KMRMm+ikU/gAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAE=" ] ]; namesList = namesList.concat(defaultNamesList); } if (options.searchByImage.addCustomNames && Array.isArray(options.searchByImage.customNamesList)) { namesList = namesList.concat(options.searchByImage.customNamesList); } function itemCreate(name, link, image) { var item = document.createElementNS(XULNS, "menuitem"); item.setAttribute("class", "menuitem-iconic"); item.setAttribute("src", image); item.setAttribute("label", name); item.link = link; popup.appendChild(item); } namesList.forEach(function(elem) { itemCreate(elem[0], elem[1], elem[2]); }); var contextMenu = this.contextMenu; popup.gObj = this; popup.setAttribute("oncommand", "this.gObj.searchByImageCommandHandler(event);"); popup.setAttribute("onclick", "checkForMiddleClick(this, event);"); } } contextSearcherObj.init(); })();
bunda1
а XULNS и XHTMLNS пусть будут
Отсутствует
2k1dmg и bunda1 совместными усилиями вы сделали очень удобную и функциональную кнопку. БОЛЬШОЕ ВАМ СПАСИБО!
Вот ещё бы для пункта отображаемого при клике на картинке сделать возможность задать поисковик по умолчанию и сделать его активным - осуществлять поиск этим поисковиком при клике на пункте контекстного меню (без захода в подменю). И тогда кнопка будет универсальная на все 100%.
Отредактировано PEAKTOP (10-10-2013 21:27:04)
1. Приму из добрых рук щедрый дар - инвайт на Хабр и Лепру
2. Бессмысленно осмысливать смысл неосмысленными мыслями!
3. Прежде чем подумать - подумай!
Отсутствует