FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
userscript/scripts/searchHelper.user.js at master · dumpmemory/userscript · GitHub
dumpmemory
userscript
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
userscript
/
scripts
/
searchHelper.user.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (69 loc) · 2.18 KB
Breadcrumbs
userscript
/
scripts
/
searchHelper.user.js
Copy path
File metadata and controls
79 lines (69 loc) · 2.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// ==UserScript==
//
@name
Search Hepler
//
@namespace
https://github.com/ywzhaiqi
//
@author
ywzhaiqi
//
@version
0.3
//
@description
让一些特殊的搜索支持搜索串
//
@include
http://kindleren.com/search.php?mod=forum&mq=*
//
@include
http://shuzi.taobao.com/item/search---50094067.htm?q=*
//
@include
http://www.xiaopian.com/?q=*
//
@include
https://www.jiumodiary.com/?q=*
//
@include
http://www.yiwulib.cn:8088/websearch.asp?q=*
//
@grant
GM_addStyle
//
@require
http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
//
@run
-at document-start
//
@noframes
// ==/UserScript==
if
(
typeof
String
.
prototype
.
includes
!=
'function'
)
{
String
.
prototype
.
includes
=
function
(
str
)
{
return
this
.
indexOf
(
str
)
!=
-
1
;
}
;
}
function
getParam
(
name
,
url
)
{
var
regexp
=
new
RegExp
(
"(?:^|\\?|#|&)"
+
name
+
"=([^&#]*)(?:$|&|#)"
,
"i"
)
,
matches
=
regexp
.
exec
(
url
||
location
.
href
)
;
return
matches
?
decodeURIComponent
(
matches
[
1
]
)
:
""
}
function
goSearch
(
param
,
input
,
submit
)
{
$
(
function
(
)
{
var
search
=
getParam
(
param
,
location
.
href
)
;
if
(
search
)
{
$
(
input
)
.
val
(
search
)
;
$
(
submit
)
.
click
(
)
;
}
}
)
;
}
// 运行在 document-start,详见 taobao 函数
function
goSearch2
(
url
,
param
)
{
var
search
=
getParam
(
param
,
location
.
href
)
;
if
(
search
)
{
location
.
href
=
url
.
replace
(
'%s'
,
search
)
;
}
}
var
ns
=
{
kindleren
:
function
(
)
{
goSearch
(
'mq'
,
'#scform_srchtxt'
,
'#scform_submit'
)
;
}
,
taobao
:
function
(
)
{
// 解决乱码问题
goSearch2
(
'http://shuzi.taobao.com/item/search-.htm?q=%s&isbook=ebook'
,
'q'
)
;
}
,
xiaopian
:
function
(
)
{
goSearch
(
'q'
,
'input[name="keyboard"]'
,
'input[name="Submit"]'
)
}
,
jiumodiary
(
)
{
goSearch
(
'q'
,
'#SearchWord'
,
'#SearchButton'
)
}
,
yiwulib
(
)
{
goSearch
(
'q'
,
'input[name="taah"]'
,
'input[name="submit"]'
)
}
}
;
function
run
(
)
{
// 自动运行符合 host 的函数
var
host
=
location
.
host
;
Object
.
keys
(
ns
)
.
some
(
function
(
key
)
{
if
(
host
.
includes
(
key
)
)
{
ns
[
key
]
(
)
;
return
true
;
}
}
)
;
}
run
(
)
;
Back
|
FazBrowse Home
|
New Git URL