您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a "Search on SauceNao" option to the context menu
当前为
- /*
- SauceNao Reverse Image Search
- Add 'Search by Image' in browser context menu when you
- right click on image to search Google with that image.
- Copyright (C) 2012 LouCypher
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>
- */
- // ==UserScript==
- // @name SauceNao Reverse Image Search
- // @description Adds a "Search on SauceNao" option to the context menu
- // @version 1.0
- // @author BasedPeacock
- // @license GPL
- // @include *
- // @exclude file://*
- // @grant GM_openInTab
- // @namespace https://greasyfork.org/users/148462
- // ==/UserScript==
- if (!("contextMenu" in document.documentElement &&
- "HTMLMenuItemElement" in window)) return;
- var body = document.body;
- body.addEventListener("contextmenu", initMenu, false);
- var menu = body.appendChild(document.createElement("menu"));
- menu.outerHTML = '<menu id="userscript-search-by-image" type="context">\
- <menuitem label="Search SauceNao for image"\
- icon="data:image/x-icon;base64,Qk02AwAAAAAAADYAAAAoAAAAEAAAABAAAAABABgAAAAAAAADAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////////////////////////////////////AAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAA////AAAA////////AAAAAAAAAAAAAAAAAAAAAAAA////////AAAA////AAAAAAAAAAAAAAAA////////////AAAAAAAAAAAAAAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AAAAAAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AAAAAAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AAAAAAAAAAAAAAAA////////////AAAAAAAAAAAAAAAA////AAAA////////AAAAAAAAAAAAAAAAAAAAAAAA////////AAAA////AAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AAAAAAAA////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"></menuitem>\
- </menu>';
- document.querySelector("#userscript-search-by-image menuitem")
- .addEventListener("click", searchImage, false);
- function initMenu(aEvent) {
- // Executed when user right click on web page body
- // aEvent.target is the element you right click on
- var node = aEvent.target;
- var item = document.querySelector("#userscript-search-by-image menuitem");
- if (node.localName == "img") {
- body.setAttribute("contextmenu", "userscript-search-by-image");
- item.setAttribute("imageURL", node.src);
- } else {
- body.removeAttribute("contextmenu");
- item.removeAttribute("imageURL");
- }
- }
- function addParamsToForm(aForm, aKey, aValue) {
- var hiddenField = document.createElement("input");
- hiddenField.setAttribute("type", "hidden");
- hiddenField.setAttribute("name", aKey);
- hiddenField.setAttribute("value", aValue);
- aForm.appendChild(hiddenField);
- }
- function searchImage(aEvent) {
- // Executed when user click on menuitem
- // aEvent.target is the <menuitem> element
- var imageURL = aEvent.target.getAttribute("imageURL");
- GM_openInTab("https://saucenao.com/search.php?url=" +
- encodeURIComponent(imageURL));
- }