您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
分别在百度和google的搜索结果页面增加搜索跳转按钮,使用到外链微软CDN的jquery-1.7.2.min.js,不懂跳墙使用GOOGLE的同学请自动忽略。自动判断百度和google对JQUERY的载入,并动态载入Jquery.js。
当前为
- // ==UserScript==
- // @name Google & baidu Switcher (ALL in One)
- // @namespace https://openuserjs.org/scripts/t3xtf0rm4tgmail.com/Google_baidu_Switcher_(ALL_in_One)
- // @author F9y4ng
- // @version 1.4.4.2
- // @description 分别在百度和google的搜索结果页面增加搜索跳转按钮,使用到外链微软CDN的jquery-1.7.2.min.js,不懂跳墙使用GOOGLE的同学请自动忽略。自动判断百度和google对JQUERY的载入,并动态载入Jquery.js。
- // @icon https://www.androidpolice.com/wp-content/uploads/2014/06/nexusae0_io2014_thumb2.png
- // @include /^https?\:\/\/[a-zA-Z0-9]*.google.[^\/]+/
- // @include http://www.baidu.com/*
- // @include https://www.baidu.com/*
- // @license MPL-2.0
- // @copyright 2015+, f9y4ng
- // @grant none
- // ==/UserScript==
- if ("undefined" == typeof (jQuery)) {
- loadJs("for_google", "https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js", callbackFunction);
- }
- else {
- $(document).ready(function () {
- function baiduswitchgoogle() {
- $('.s_btn_wr').after('<div class="s_btn_wr bg" style="display:inline-block;margin-left:10px\
- "><input type="button" id="ggyx" value="Google一下" class="bg s_btn" ></div>');
- $('#ggyx').on({
- click: function () {
- window.open("https://www.google.com/search?newwindow=1&hl=zh-CN&source=hp&q=" + encodeURIComponent($('#kw').val()));
- return false;
- }
- });
- }
- if (GetUrlParam("wd").length > 0 || window.location.href.lastIndexOf("/s?") > 0) {
- baiduswitchgoogle();
- }
- //2018/11/07 F9y4ng 检测从baidu首页进入的搜索(修正自动提交的Bug)
- if (/^http(s)?:\/\/(www\.)?baidu\.com\/$/ig.test(window.location.href)) {
- $("#kw").on("blur", function () {
- if ($('#kw').val().length > 0) {
- setTimeout(function () {
- if ($('#ggyx').length < 1 && GetUrlParam("wd").length > 0) {
- baiduswitchgoogle();
- }
- }, 600);
- }
- });
- }
- });
- }
- function callbackFunction() {
- $(document).ready(function () {
- function googleswitchbaidu() {
- $('#tsf').prepend('<div id="sfdiv_bd" style="display:inline-block;position:relative;height:0px;width:110px;right:-115px;top:-4px;float:right;">\
- <button id="bdyx" class="lsbb kpbb" style="height:45px;margin-top:4px;cursor:pointer" type="button"><span class="sbico" style="color:#fff;margin-top:-4px">\
- <svg focusable="false" style="fill: #fff;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0\
- 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 \
- 9.5 11.99 14 9.5 14z"></path></svg></span><span style="font-size:16px;">百度一下</span></button></div>');
- $('#sfdiv_bd').off("click").on({
- click: function () {
- var kw = $('input[name="q"]').val();
- //获取属性标签容错
- if ("undefined" == typeof (kw)) {
- kw = GetUrlParam("q");
- }
- window.open("https://www.baidu.com/s?ie=utf-8&rqlang=cn&wd=" + encodeURIComponent(kw));
- return false;
- }
- });
- }
- if (window.location.hash.lastIndexOf("q=") > 0 || window.location.search.lastIndexOf("q=") > 0) {
- googleswitchbaidu();
- }
- //2018/11/07 F9y4ng GOOGLE首页自动提交搜索修正
- if (/^http(s)?:\/\/(www\.)?google\.\w+(\.\w+)?\/$/ig.test(window.location.href) || GetUrlParam("q") === null || GetUrlParam("q") === "") {
- var gfm = $('input[name="q"]');
- if ("undefined" == typeof (gfm)) {
- gfm = $("input[role='combobox']");
- }
- gfm.off('click').on({
- blur: function () {
- if (gfm.val().length > 0) {
- $("form").submit();
- }
- }
- });
- }
- });
- }
- function loadJs(sid, jsurl, callback) {
- var nodeHead = document.getElementsByTagName('head')[0];
- var nodeScript = null;
- if (document.getElementById(sid) === null) {
- nodeScript = document.createElement('script');
- nodeScript.setAttribute('type', 'text/javascript');
- nodeScript.setAttribute('src', jsurl);
- nodeScript.setAttribute('id', sid);
- if (callback !== null) {
- nodeScript.onload = nodeScript.onreadystatechange = function () {
- if (nodeScript.ready) {
- return false;
- }
- if (!nodeScript.readyState || nodeScript.readyState == "loaded" || nodeScript.readyState == 'complete') {
- nodeScript.ready = true;
- callback();
- }
- };
- }
- nodeHead.appendChild(nodeScript);
- }
- else {
- if (callback !== null) {
- callback();
- }
- }
- }
- function GetUrlParam(paraName) {
- var url = document.location.toString();
- var arrObj = url.split("?");
- if (arrObj.length > 1) {
- var arrPara = arrObj[1].split("&");
- var arr;
- for (var i = 0; i < arrPara.length; i++) {
- arr = arrPara[i].split("=");
- if (arr !== null && arr[0] == paraName) {
- return arr[1];
- }
- }
- return "";
- }
- else {
- return "";
- }
- }