您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add search option to search on Userscripts.org and *cough* OpenUserJS.org.
当前为
// ==UserScript== // @id greasyfork-search-other-sites@loucypher // @name Greasy Fork - Search other sites // @namespace https://github.com/LouCypher/userscripts // @description Add search option to search on Userscripts.org and *cough* OpenUserJS.org. // @version 1.0 // @author LouCypher // @license MIT License // @contributionURL http://loucypher.github.io/userscripts/donate.html?Greasy+Fork+-+Search+other+sites // @homepageURL https://greasyfork.org/scripts/259 // @supportURL https://greasyfork.org/scripts/259/feedback // @resource LICENSE https://raw.github.com/LouCypher/userscripts/master/greasyfork/search-other-sites/LICENSE.txt // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/greasyfork/search-other-sites/CHANGELOG.txt // @include https://greasyfork.org/* // @grant none // ==/UserScript== function $(aSelector, aNode) { return (aNode || document).querySelector(aSelector); } function createElement(aTagName) { return document.createElement(aTagName); } function createText(aText) { return document.createTextNode(aText); } function createLink(aURL, aText, aName) { var link = createElement("a"); aURL && (link.href = aURL); aText && (link.textContent = aText); aName && (link.name = aName); return link; } function addStyle(aCSS) { var style = createElement("style"); style.type = "text/css"; style.textContent = aCSS; if (document.head) document.head.appendChild(style); else document.documentElement.appendChild(style); return style; } var sites = [ { text: "Userscripts.org", url: "http://userscripts.org/scripts/search?q=" }, { text: "OpenUserJS.org", url: "https://openuserjs.org/search/" } ]; function onsubmit(aEvent) { var searchURL; var query = aEvent.target.q.value; var site = $("#search-other-sites"); switch (parseInt(site.value)) { case 2: searchURL = sites[1].url; break; case 1: searchURL = sites[0].url; break; default: searchURL = null; } if (searchURL) { aEvent.preventDefault(); location.assign(searchURL + encodeURIComponent(query)); } } var form = $("#script-search"); if (form) { addStyle("#search-other-sites{width:19px;direction:rtl}" + "#link-other-sites li{line-height:1.5em}"); var select = form.insertBefore(createElement("select"), form.lastChild); select.id = "search-other-sites"; select.title = "Search other sites"; select.innerHTML = '<option value="0">Greasy Fork</option>' + '<option value="1">' + sites[0].text + '</option>' + '<option value="2">' + sites[1].text + '</option>'; form.addEventListener("submit", onsubmit); } if (location.pathname === "/scripts/search") { var xpath = "//p[@id='script-list-sort']/following-sibling::p[text()='No scripts found.']"; var p = document.evaluate(xpath, document, null, 9, null).singleNodeValue; if (p) { var query = $("#script-search").q.value; p.appendChild(createElement("br")); p.appendChild(createText("Search '" + query + "' on other sites:")); var ul = document.body.insertBefore(createElement("ul"), p.nextSibling); ul.id = "link-other-sites"; var li; sites.forEach(function(site) { li = ul.appendChild(createElement("li")); li.appendChild(createLink(site.url + encodeURIComponent(query), site.text)); }); } }