|
4 | 4 | // @name:zh-TW 搜索醬 |
5 | 5 | // @name:ja 検索ちゃん |
6 | 6 | // @namespace hoothin |
7 | | -// @version 1.6.5.6.8 |
| 7 | +// @version 1.6.5.6.9 |
8 | 8 | // @description Jump to any search engine quickly and easily, the most powerful, most complete search enhancement script! |
9 | 9 | // @description:zh-CN 又一个多搜索引擎切换脚本,在搜索时一键跳转各大搜索引擎,支持任意页面右键划词搜索与全面自定义 |
10 | 10 | // @description:zh-TW 又一個多搜尋引擎切換脚本,在搜索時一鍵跳轉各大搜尋引擎,支持任意頁面右鍵劃詞搜索與全面自定義 |
|
970 | 970 | .search-jumper-isTargetLink>.search-jumper-type { |
971 | 971 | display: none; |
972 | 972 | } |
| 973 | + #search-jumper>.search-jumper-searchBar>.search-jumper-type.search-jumper-logo { |
| 974 | + display: inline-flex; |
| 975 | + } |
973 | 976 | .search-jumper-searchBar>.search-jumper-type.search-jumper-targetAll { |
974 | 977 | display: inline-flex; |
975 | 978 | } |
|
1058 | 1061 | } |
1059 | 1062 | .search-jumper-word { |
1060 | 1063 | background: black; |
1061 | | - color: white!important; |
1062 | | - text-shadow: 0px 0px 5px black; |
| 1064 | + color: #f5f7fa!important; |
| 1065 | + text-shadow: 0px 0px 5px #707070; |
1063 | 1066 | font-family: system-ui,Arial,sans-serif; |
1064 | 1067 | font-weight: bold; |
1065 | 1068 | border-radius: ${20 * this.scale}px!important; |
|
1069 | 1072 | height: ${32 * this.scale}px; |
1070 | 1073 | min-width: ${32 * this.scale}px; |
1071 | 1074 | min-height: ${32 * this.scale}px; |
1072 | | - letter-spacing: 2px; |
| 1075 | + letter-spacing: 0px; |
1073 | 1076 | } |
1074 | 1077 | a.search-jumper-word { |
1075 | 1078 | background: #505050; |
|
1101 | 1104 | height: ${20 * this.scale}px; |
1102 | 1105 | margin: auto; |
1103 | 1106 | } |
| 1107 | + .search-jumper-searchBar .search-jumper-btn.search-jumper-word:hover { |
| 1108 | + background: black; |
| 1109 | + } |
1104 | 1110 | .search-jumper-searchBar .search-jumper-btn:hover { |
1105 | 1111 | -webkit-transform:scale(1.2); |
1106 | 1112 | -moz-transform:scale(1.2); |
|
1879 | 1885 | ele.classList.add("search-jumper-word"); |
1880 | 1886 | let word = document.createElement("span"); |
1881 | 1887 | word.innerText = name.substr(0, 3).trim(); |
| 1888 | + if (!/^\w+$/.test(word.innerText)) word.innerText = word.innerText.substr(0, 2); |
1882 | 1889 | ele.appendChild(word); |
1883 | 1890 | let img = document.createElement("img"); |
1884 | 1891 | img.style.opacity = 0; |
|
3049 | 3056 | } |
3050 | 3057 | }); |
3051 | 3058 | } |
| 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 | + } |
3052 | 3067 | document.addEventListener('mousedown', e => { |
3053 | 3068 | if (e.target.classList.contains('search-jumper-btn') || |
3054 | 3069 | e.target.tagName === 'CANVAS' || |
|
3067 | 3082 | (e.which === 1 || e.which === 2) && !searchData.prefConfig.leftMouse) { |
3068 | 3083 | return; |
3069 | 3084 | } |
| 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 | + } |
3070 | 3095 | let selectImg = e.target.tagName === 'IMG'; |
3071 | 3096 | let matchKey = searchData.prefConfig.altKey || |
3072 | 3097 | searchData.prefConfig.ctrlKey || |
|
3078 | 3103 | searchBar.showInPage(); |
3079 | 3104 | shown = true; |
3080 | 3105 | }, 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 | + }; |
3081 | 3114 | let mouseUpHandler = e => { |
3082 | 3115 | if (shown) { |
3083 | 3116 | e.stopPropagation(); |
|
3086 | 3119 | searchBar.showInPage(); |
3087 | 3120 | } |
3088 | 3121 | clearTimeout(showToolbarTimer); |
| 3122 | + clearTimeout(mouseMoveTimer); |
3089 | 3123 | document.removeEventListener('mouseup', mouseUpHandler, false); |
| 3124 | + document.removeEventListener('mousemove', mouseMoveHandler, false); |
3090 | 3125 | }; |
3091 | 3126 | document.addEventListener('mouseup', mouseUpHandler, false); |
3092 | 3127 | }, true); |
|
0 commit comments