|

楼主 |
发表于 2023-12-13 01:08:47
|
显示全部楼层
// ==UserScript==0 J7 Z$ c* Z) Y$ l
// @name Google on baidu
; _% w' L6 F; z2 W// @namespace http://tampermonkey.net/3 _# [9 |: C y' V
// @version 0.1
' f1 y- L- H/ ~% z" n// @description Google it!
0 z4 }0 i1 P: a; H: c' O// @author ggg
* H# E; Y. s8 P/ w// @match https://www.baidu.com/*, v: r& \- i' |4 n( W
// @grant GM_openInTab
9 D0 U4 \- }4 w% D; Y8 N& w# O// ==/UserScript==0 j8 m5 L1 l/ D0 a2 G, m- b" U
(function() {3 d, y0 I- D3 \. S5 C
'use strict';2 U; {5 v+ n! J: q f
$('#su').after('<input type="button" id="google" value="Google一下" class="btn self-btn bg s_btn" style="background-color:grey;" />');
6 ]" d7 @* T# v# o! |7 l9 p $("#google").click(function() {/ t! K# d' _- G I# G
googleIt();
) U- h$ ]0 W$ I });3 c; c1 ]8 P7 h" e! j
function googleIt() {
/ h& i! {) g6 l2 w- i$ k% u var searchText = $('#kw').val();
6 H5 |4 m! O* @6 v# o GM_openInTab(getGoogleUrl(searchText), false);
; `) {# Y. f& a: z0 _) x" X }/ u( e& R7 m; L& P6 E2 Z
function getGoogleUrl(searchText) {
. t! k ]. m, @2 x) \9 T H1 a return 'https://www.google.com/search?q=' + searchText;
; c q# S/ h# F/ I3 Z) F: y0 s, J }, C D: n' }( g+ _( X
})(); |
|