Skip to content

Commit 2746ead

Browse files
committed
Update searchJumper.user.js
1 parent 0db1c56 commit 2746ead

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

SearchJumper/searchJumper.user.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @name:zh-TW 搜索醬
55
// @name:ja 検索ちゃん
66
// @namespace hoothin
7-
// @version 1.6.5.6.8
7+
// @version 1.6.5.6.9
88
// @description Jump to any search engine quickly and easily, the most powerful, most complete search enhancement script!
99
// @description:zh-CN 又一个多搜索引擎切换脚本,在搜索时一键跳转各大搜索引擎,支持任意页面右键划词搜索与全面自定义
1010
// @description:zh-TW 又一個多搜尋引擎切換脚本,在搜索時一鍵跳轉各大搜尋引擎,支持任意頁面右鍵劃詞搜索與全面自定義
@@ -970,6 +970,9 @@
970970
.search-jumper-isTargetLink>.search-jumper-type {
971971
display: none;
972972
}
973+
#search-jumper>.search-jumper-searchBar>.search-jumper-type.search-jumper-logo {
974+
display: inline-flex;
975+
}
973976
.search-jumper-searchBar>.search-jumper-type.search-jumper-targetAll {
974977
display: inline-flex;
975978
}
@@ -1058,8 +1061,8 @@
10581061
}
10591062
.search-jumper-word {
10601063
background: black;
1061-
color: white!important;
1062-
text-shadow: 0px 0px 5px black;
1064+
color: #f5f7fa!important;
1065+
text-shadow: 0px 0px 5px #707070;
10631066
font-family: system-ui,Arial,sans-serif;
10641067
font-weight: bold;
10651068
border-radius: ${20 * this.scale}px!important;
@@ -1069,7 +1072,7 @@
10691072
height: ${32 * this.scale}px;
10701073
min-width: ${32 * this.scale}px;
10711074
min-height: ${32 * this.scale}px;
1072-
letter-spacing: 2px;
1075+
letter-spacing: 0px;
10731076
}
10741077
a.search-jumper-word {
10751078
background: #505050;
@@ -1101,6 +1104,9 @@
11011104
height: ${20 * this.scale}px;
11021105
margin: auto;
11031106
}
1107+
.search-jumper-searchBar .search-jumper-btn.search-jumper-word:hover {
1108+
background: black;
1109+
}
11041110
.search-jumper-searchBar .search-jumper-btn:hover {
11051111
-webkit-transform:scale(1.2);
11061112
-moz-transform:scale(1.2);
@@ -1879,6 +1885,7 @@
18791885
ele.classList.add("search-jumper-word");
18801886
let word = document.createElement("span");
18811887
word.innerText = name.substr(0, 3).trim();
1888+
if (!/^\w+$/.test(word.innerText)) word.innerText = word.innerText.substr(0, 2);
18821889
ele.appendChild(word);
18831890
let img = document.createElement("img");
18841891
img.style.opacity = 0;
@@ -3049,6 +3056,14 @@
30493056
}
30503057
});
30513058
}
3059+
let clientRect;
3060+
if (searchData.prefConfig.leftMouse) {
3061+
document.addEventListener('selectionchange', (e) => {
3062+
const selection = window.getSelection();
3063+
const range = selection.getRangeAt(0);
3064+
clientRect = range.getBoundingClientRect();
3065+
});
3066+
}
30523067
document.addEventListener('mousedown', e => {
30533068
if (e.target.classList.contains('search-jumper-btn') ||
30543069
e.target.tagName === 'CANVAS' ||
@@ -3067,6 +3082,16 @@
30673082
(e.which === 1 || e.which === 2) && !searchData.prefConfig.leftMouse) {
30683083
return;
30693084
}
3085+
if (e.which === 1 && clientRect) {
3086+
if (e.clientX > clientRect.left && e.clientX < clientRect.left + clientRect.width &&
3087+
e.clientY > clientRect.top && e.clientY < clientRect.top + clientRect.height) {
3088+
searchBar.showInPage();
3089+
shown = true;
3090+
e.stopPropagation();
3091+
e.preventDefault();
3092+
return false;
3093+
}
3094+
}
30703095
let selectImg = e.target.tagName === 'IMG';
30713096
let matchKey = searchData.prefConfig.altKey ||
30723097
searchData.prefConfig.ctrlKey ||
@@ -3078,6 +3103,14 @@
30783103
searchBar.showInPage();
30793104
shown = true;
30803105
}, parseInt(searchData.prefConfig.longPressTime));
3106+
let mouseMoveTimer = setTimeout(() => {
3107+
document.addEventListener('mousemove', mouseMoveHandler, false);
3108+
}, 10);
3109+
let mouseMoveHandler = e => {
3110+
clearTimeout(showToolbarTimer);
3111+
clearTimeout(mouseMoveTimer);
3112+
document.removeEventListener('mousemove', mouseMoveHandler, false);
3113+
};
30813114
let mouseUpHandler = e => {
30823115
if (shown) {
30833116
e.stopPropagation();
@@ -3086,7 +3119,9 @@
30863119
searchBar.showInPage();
30873120
}
30883121
clearTimeout(showToolbarTimer);
3122+
clearTimeout(mouseMoveTimer);
30893123
document.removeEventListener('mouseup', mouseUpHandler, false);
3124+
document.removeEventListener('mousemove', mouseMoveHandler, false);
30903125
};
30913126
document.addEventListener('mouseup', mouseUpHandler, false);
30923127
}, true);

0 commit comments

Comments
 (0)