快捷交叉验证搜索

输入你检索的主题+选择默认的交叉验证关键词,辅助你快速交叉验证。支持双语

  1. // ==UserScript==
  2. // @name 快捷交叉验证搜索
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 输入你检索的主题+选择默认的交叉验证关键词,辅助你快速交叉验证。支持双语
  6. // @author awyugan
  7. // @match https://www.google.com/search?q=*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 中英文词汇
  16. const zhWords = {
  17. actionPhrases: ['评论', '批评', '回应', '反对', '真实吗', '靠谱吗', '可信吗', '不能', '不要', '不会'],
  18. negativeTerms: ['错误', '缺陷', '不足', '问题', '失败', '误解', '骗子', '骗局', '非法', '假的', '欺骗', '圈套', '陷阱'],
  19. title: '快捷交叉验证搜索',
  20. examples: [
  21. '最好 vs 最差',
  22. '裁员 vs 扩招',
  23. '倒闭 vs 扩张'
  24. ]
  25. };
  26.  
  27. const enWords = {
  28. actionPhrases: ['Comment', 'Reply to', 'criticize', 'is real', 'is true', 'why not'],
  29. negativeTerms: ['bad', 'worst', 'terrible', 'awful', 'believable', 'likely'],
  30. title: 'Negation Cross Validation',
  31. examples: [
  32. 'best vs worst',
  33. 'layoff vs hire',
  34. 'collapse vs expand'
  35. ]
  36. };
  37.  
  38. let currentLang = 'zh';
  39. let words = zhWords;
  40.  
  41. // 添加快捷搜索按钮
  42. const searchButton = document.createElement('button');
  43. searchButton.innerText = '快捷搜索';
  44. searchButton.style.position = 'fixed';
  45. searchButton.style.bottom = '10px';
  46. searchButton.style.right = '10px';
  47. searchButton.style.zIndex = 1000;
  48. searchButton.style.padding = '10px';
  49. searchButton.style.backgroundColor = '#007BFF';
  50. searchButton.style.color = '#FFFFFF';
  51. searchButton.style.border = 'none';
  52. searchButton.style.borderRadius = '5px';
  53. searchButton.style.cursor = 'pointer';
  54.  
  55. document.body.appendChild(searchButton);
  56.  
  57. // 创建高级搜索框
  58. const searchPanel = document.createElement('div');
  59. searchPanel.style.position = 'fixed';
  60. searchPanel.style.bottom = '100px';
  61. searchPanel.style.right = '10px';
  62. searchPanel.style.zIndex = 1000;
  63. searchPanel.style.padding = '20px';
  64. searchPanel.style.backgroundColor = '#f8f9fa';
  65. searchPanel.style.border = '1px solid #ced4da';
  66. searchPanel.style.borderRadius = '5px';
  67. searchPanel.style.display = 'none';
  68. searchPanel.style.width = '300px';
  69. searchPanel.style.boxShadow = '0 0 10px rgba(0,0,0,0.1)';
  70.  
  71. // 标题和语言切换按钮
  72. const panelHeader = document.createElement('div');
  73. panelHeader.style.display = 'flex';
  74. panelHeader.style.justifyContent = 'space-between';
  75. panelHeader.style.alignItems = 'center';
  76. const panelTitle = document.createElement('h4');
  77. panelTitle.innerText = words.title;
  78. panelHeader.appendChild(panelTitle);
  79. const langButton = document.createElement('button');
  80. langButton.innerText = 'Switch to English';
  81. langButton.style.padding = '5px';
  82. langButton.style.backgroundColor = '#28a745';
  83. langButton.style.color = '#FFFFFF';
  84. langButton.style.border = 'none';
  85. langButton.style.borderRadius = '5px';
  86. langButton.style.cursor = 'pointer';
  87. panelHeader.appendChild(langButton);
  88. searchPanel.appendChild(panelHeader);
  89.  
  90. // 关键词输入框
  91. const keywordInput = document.createElement('input');
  92. keywordInput.type = 'text';
  93. keywordInput.placeholder = currentLang === 'zh' ? '请输入搜索关键词' : 'Please enter a search keyword';
  94. keywordInput.style.width = '100%';
  95. keywordInput.style.padding = '10px';
  96. keywordInput.style.margin = '10px 0';
  97. keywordInput.style.border = '1px solid #ced4da';
  98. keywordInput.style.borderRadius = '5px';
  99. searchPanel.appendChild(keywordInput);
  100.  
  101. // 词汇选择容器
  102. const wordContainer = document.createElement('div');
  103. searchPanel.appendChild(wordContainer);
  104.  
  105. // 生成词汇选择按钮
  106. let selectedWords = [];
  107. function generateWordButtons() {
  108. wordContainer.innerHTML = '';
  109. ['actionPhrases', 'negativeTerms'].forEach(type => {
  110. words[type].forEach(word => {
  111. const wordButton = document.createElement('button');
  112. wordButton.innerText = word;
  113. wordButton.style.margin = '5px';
  114. wordButton.style.padding = '5px';
  115. wordButton.style.border = '1px solid #007BFF';
  116. wordButton.style.borderRadius = '5px';
  117. wordButton.style.cursor = 'pointer';
  118. wordButton.addEventListener('click', () => {
  119. if (!selectedWords.includes(word)) {
  120. selectedWords.push(word);
  121. wordButton.disabled = true;
  122. }
  123. });
  124. wordContainer.appendChild(wordButton);
  125. });
  126. });
  127. }
  128.  
  129. // 添加词汇按钮
  130. const addWordButton = document.createElement('button');
  131. addWordButton.innerText = '+';
  132. addWordButton.style.margin = '5px';
  133. addWordButton.style.padding = '5px';
  134. addWordButton.style.border = '1px solid #007BFF';
  135. addWordButton.style.borderRadius = '5px';
  136. addWordButton.style.cursor = 'pointer';
  137. addWordButton.addEventListener('click', () => {
  138. const newWord = prompt(currentLang === 'zh' ? '请输入新词汇:' : 'Please enter a new word:');
  139. if (newWord) {
  140. selectedWords.push(newWord);
  141. generateWordButtons(); // 重新生成词汇选择按钮,避免重复添加
  142. }
  143. });
  144. wordContainer.appendChild(addWordButton);
  145.  
  146. // 添加反义词提示
  147. const oppositeWordsDiv = document.createElement('div');
  148. oppositeWordsDiv.innerHTML = `<p>反义词举例:</p><ul>${words.examples.map(example => `<li>${example}</li>`).join('')}</ul>`;
  149. oppositeWordsDiv.style.marginTop = '10px';
  150. oppositeWordsDiv.style.padding = '10px';
  151. oppositeWordsDiv.style.backgroundColor = '#f8f9fa';
  152. oppositeWordsDiv.style.border = '1px solid #ced4da';
  153. oppositeWordsDiv.style.borderRadius = '5px';
  154. searchPanel.appendChild(oppositeWordsDiv);
  155.  
  156. // 搜索按钮
  157. const submitButton = document.createElement('button');
  158. submitButton.innerText = currentLang === 'zh' ? '执行搜索' : 'Perform Search';
  159. submitButton.style.marginTop = '10px';
  160. submitButton.style.padding = '10px';
  161. submitButton.style.backgroundColor = '#007BFF';
  162. submitButton.style.color = '#FFFFFF';
  163. submitButton.style.border = 'none';
  164. submitButton.style.borderRadius = '5px';
  165. submitButton.style.cursor = 'pointer';
  166. submitButton.style.width = '100%';
  167. submitButton.addEventListener('click', () => {
  168. const userInput = keywordInput.value;
  169. if (userInput) {
  170. const queries = generateSearchQueries(userInput);
  171. queries.forEach(query => performSearch(query));
  172. searchPanel.style.display = 'none';
  173. }
  174. });
  175. searchPanel.appendChild(submitButton);
  176.  
  177. document.body.appendChild(searchPanel);
  178.  
  179. // 切换语言
  180. langButton.addEventListener('click', () => {
  181. currentLang = currentLang === 'zh' ? 'en' : 'zh';
  182. words = currentLang === 'zh' ? zhWords : enWords;
  183. langButton.innerText = currentLang === 'zh' ? 'Switch to English' : '切换到中文';
  184. panelTitle.innerText = words.title;
  185. keywordInput.placeholder = currentLang === 'zh' ? '请输入搜索关键词' : 'Please enter a search keyword';
  186. oppositeWordsDiv.innerHTML = `<p>反义词举例:</p><ul>${words.examples.map(example => `<li>${example}</li>`).join('')}</ul>`;
  187. generateWordButtons();
  188. });
  189.  
  190. // 显示高级搜索框
  191. searchButton.addEventListener('click', () => {
  192. selectedWords = [];
  193. keywordInput.value = '';
  194. searchPanel.style.display = 'block';
  195. generateWordButtons();
  196. });
  197.  
  198. // 搜索表达式和关键词
  199. function generateSearchQueries(userInput) {
  200. let queries = [];
  201. if (selectedWords.length > 0) {
  202. const combinedWords = selectedWords.join(' OR ');
  203. queries.push(`"${userInput}" AND (${combinedWords})`);
  204. } else {
  205. queries.push(`"${userInput}"`);
  206. }
  207. return queries;
  208. }
  209.  
  210. function performSearch(query) {
  211. const searchUrl = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
  212. window.open(searchUrl, '_blank');
  213. }
  214. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址