|

楼主 |
发表于 2023-12-13 01:08:47
|
显示全部楼层
// ==UserScript==2 O2 C3 d+ N! F" ^2 X" C# F
// @name Google on baidu; ?& v7 T5 u; C
// @namespace http://tampermonkey.net/
. t. }6 U$ S0 H: L; q// @version 0.1% R, K. e3 P* Y9 v6 u
// @description Google it!
3 E9 M, c# j% ]; ?7 [0 Z) m// @author ggg* ~0 N. c0 m* k- N; b. W0 ]
// @match https://www.baidu.com/*/ _5 M* U. i& M$ M* s9 i
// @grant GM_openInTab
0 R- m' o% }8 r; `// ==/UserScript==
3 g9 j6 | T) L; ](function() {- {% v) R0 f4 D+ l$ a
'use strict';% D7 b. d* R" |8 S+ n
$('#su').after('<input type="button" id="google" value="Google一下" class="btn self-btn bg s_btn" style="background-color:grey;" />');
% {: T2 K9 f! M1 c2 [9 y $("#google").click(function() {
% Z+ H* u* R1 r+ X0 p6 @0 h" H% X7 W8 r googleIt();! ?8 g. v0 F% \0 y/ `: D7 \ r
});5 W/ h/ O; x. n( n
function googleIt() {: F: g. ^0 o: I o/ K, g2 C- H
var searchText = $('#kw').val();
- O; A h- j5 W& y4 r ]4 t9 o GM_openInTab(getGoogleUrl(searchText), false);5 y; I3 ]8 v% s
}
6 h5 t; `3 v6 L0 K' Q* g' r function getGoogleUrl(searchText) {0 P$ P) o$ D# I' N
return 'https://www.google.com/search?q=' + searchText;
1 D! G2 Z, d: X* `8 \ }
. A6 ?' V8 M; j$ b/ c+ p! h( ~})(); |
|