To search scripts using Google Search
目前為
// ==UserScript==
// @name GreasyFork Scripts by Google Search
// @namespace http://tampermonkey.net/
// @version 0.1.4
// @description To search scripts using Google Search
// @author CY Fung
// @match https://greasyfork.org/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant none
// @license MIT
// ==/UserScript==
(function () {
'use strict';
let input = document.querySelector('form input[name="q"]');
if (!(input instanceof HTMLInputElement)) return;
let form = input.closest('form');
if (!(form instanceof HTMLFormElement)) return;
form.addEventListener('submit', function (evt) {
let form = evt.target;
if (!(form instanceof HTMLFormElement)) return;
let input = form.querySelector('input[name="q"]');
if (!(input instanceof HTMLInputElement)) return;
if (input.value) {
evt.preventDefault();
let m = "-inurl%3A%22%2Fusers%2F%22+-inurl%3A%22%2Fdiscussions%22-inurl%3A%22%2Fstats%22+-inurl%3A%22%2Ffeedback%22+-inurl%3A%22%2Fcode%22+-inurl%3A%22q%3D%22+-inurl%3A%22%2Fby-site%2F%22+inurl%3A%22%2Fscripts%2F%22+site%3Agreasyfork.org";
location.href = `https://www.google.com/search?q=${encodeURIComponent(input.value)}+${m}&lr=lang_${document.documentElement.lang}`
}
})
// Your code here...
})();