// ==UserScript== // @name 万能页内选中搜索【失效联系作者24小时更新】 // @namespace http://tampermonkey.net/ // @version 1.0.2 // @description 任何页面选中以后都可以快捷搜索,实现不跳出网页浏览进行搜索,目前支持必应搜索。 // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js // @author 蜡小新 // @match *://*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/445266/%E4%B8%87%E8%83%BD%E9%A1%B5%E5%86%85%E9%80%89%E4%B8%AD%E6%90%9C%E7%B4%A2%E3%80%90%E5%A4%B1%E6%95%88%E8%81%94%E7%B3%BB%E4%BD%9C%E8%80%8524%E5%B0%8F%E6%97%B6%E6%9B%B4%E6%96%B0%E3%80%91.user.js // @updateURL https://update.greasyfork.icu/scripts/445266/%E4%B8%87%E8%83%BD%E9%A1%B5%E5%86%85%E9%80%89%E4%B8%AD%E6%90%9C%E7%B4%A2%E3%80%90%E5%A4%B1%E6%95%88%E8%81%94%E7%B3%BB%E4%BD%9C%E8%80%8524%E5%B0%8F%E6%97%B6%E6%9B%B4%E6%96%B0%E3%80%91.meta.js // ==/UserScript== (function() { 'use strict'; var content = ""; $("body").bind('mouseup', function(e) { processSelection(e); }); function processSelection(e) { var text = getSelectedText(); if (!!text && text != "" && text.length != 0) { showBubble(e, text); } else { hideBubble(); } } function getSelectedText() { var text = ""; if (window.getSelection) { text = window.getSelection() .toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange() .text; } return text; } function showBubble(e, text) { content = text; if($('#any-searcher-bubble').length == 0) { $("body").append("
点我页内搜索
"); $("#any-searcher-bubble").click(function(e) { if($("#any-searcher-iframe-container").length ==0) { $("body").append("
"+ "
X
"+ "
Reset
"+ "
Left
"+ "
Right
"+ "
"); $("#any-searcher-iframe-x").click(function(e){ $("#any-searcher-iframe-container").hide(); }); $("#any-searcher-iframe-reset").click(function(e){ $('#any-searcher-iframe').attr('src', $('#any-searcher-iframe').attr('src')); }); $("#any-searcher-iframe-left").click(function(e){ $('#any-searcher-iframe-container').hide(); $('#any-searcher-iframe-container').css('left',"10px"); $('#any-searcher-iframe-container').show(); }); $("#any-searcher-iframe-right").click(function(e){ $('#any-searcher-iframe-container').hide(); $('#any-searcher-iframe-container').css('right',"10px"); $('#any-searcher-iframe-container').css('left',""); $('#any-searcher-iframe-container').show(); }); $('#any-searcher-iframe-container').css('left',"10px"); } $('#any-searcher-iframe-container').css('top', e.pageY - 40 + "px"); $('#any-searcher-iframe-container').show(); e.stopPropagation(); }); } $('#any-searcher-bubble').css('top', e.pageY - 40 + "px"); $('#any-searcher-bubble').css('left', e.pageX + 20 + "px"); $('#any-searcher-bubble').show(); } function hideBubble() { $('#any-searcher-bubble').hide(); } function makeASelf(){ var elements = $("a"); for(var i = 0 ; i < elements.length; i++) { $(elements[i]).attr("target","_self") } } window.setInterval(makeASelf, 500); })();