您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
增加了快捷设置文件类型过滤搜索和网站过滤搜索
当前为
// ==UserScript== // @name [kesai]google搜索选项扩展 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 增加了快捷设置文件类型过滤搜索和网站过滤搜索 // @author kesai // @match https://www.google.com/* // @match https://www.google.co.jp/* // @match https://www.google.com.hk/* // @require https://code.jquery.com/jquery-3.3.1.min.js // @grant none // ==/UserScript== (function() { 'use strict'; // Your code here... let fileExtArray = ['doc', 'pdf', 'xls', 'ppt', 'rtf', 'kml']; function initMenus() { initfileType(); initSiteFilter(); } function initfileType() { $(".hdtb-mn-cont").append($('<span class="hQKUmb"></span>')); var div = $('<div class="hdtb-mn-hd" aria-haspopup="true" role="button" tabindex="0" aria-label="所有网页和文件"><div class="mn-hd-txt">所有网页和文件</div><span class="mn-dwn-arw"></span></div>'); $(".hdtb-mn-cont").append(div); let ul = $('<ul class="hdtbU hdtb-mn-o" aria-expanded="false" style="display:none;left: 410.977px; top: 25px; min-width: 148px;"><li class="hdtbItm hdtbSel" id="li_" tabindex="0">所有网页和文件(不限格式)</li></ul>'); var i = 1; fileExtArray.forEach(function(fileExt) { var id = "li_" + i; //debugger; var li = $('<li class="hdtbItm" id="' + id + '"><a class="q qs">' + fileExt + '</a></li>'); ul.append(li) i++; }) $(".hdtb-mn-cont").append(ul); div.bind("click", function() { if (ul.css("display") === "block") ul.css("display", "none"); else ul.css("display", "block") }); var regex = /filetype:[a-zA-Z]{3}/i; var isExistFileTypeReg = /filetype:*/i; ul.find("li").bind("click", function() { var str = $(".gLFyf.gsfi").val(); var filetype = "filetype:" + $(this).text(); if (isExistFileTypeReg.test(str)) { var regex = /filetype:[a-zA-Z]{1,4}/i; if (regex.test(str)) $(".gLFyf.gsfi").val(str.replace(regex, filetype)); } else { $(".gLFyf.gsfi").val($(".gLFyf.gsfi").val() + " " + filetype); } ul.css("display", "none"); $(".Tg7LZd").trigger("click"); }); } function initSiteFilter() { $(".hdtb-mn-cont").append($('<span class="hQKUmb"></span>')); var div = $('<div class="hdtb-mn-hd" aria-haspopup="true" role="button" tabindex="0" aria-label="站点内检索"><div class="mn-hd-txt">站点内检索</div><span class="mn-dwn-arw"></span></div>'); $(".hdtb-mn-cont").append(div); let ul = $('<ul class="hdtbU hdtb-mn-o" aria-expanded="false" style="display:none;left: 410.977px; top: 25px; min-width: 148px;"><li><input id="input_site" type="txt" autocomplete="off" value="" placeholder="例如:baidu.com"><a id="btn_site_OK">确认</a></li></ul>'); $(".hdtb-mn-cont").append(ul); div.bind("click", function() { if (ul.css("display") === "block") ul.css("display", "none"); else ul.css("display", "block") }); $("#btn_site_OK").bind("click", function() { var url = $("#input_site").val(); //没有进行正则表达式的验证 $(".gLFyf.gsfi").val($(".gLFyf.gsfi").val() + " " + "site:" + url); $(".Tg7LZd").trigger("click"); ul.css("display", "none"); }); } $(function() { //initMenus(); setTimeout(function() { initMenus(); }, 2000); }) })();