Change search result for Google and Bing

change or hide search results of Google & Bing

  1. // ==UserScript==
  2. // @id Change_search_result_for_Google_and_Bing@noi
  3. // @name Change search result for Google and Bing
  4. // @version 2.02
  5. // @copyright Noi & Noisys & NoiSystem & NoiProject
  6. // @license https://creativecommons.org/licenses/by-nc-sa/3.0/
  7. // @author noi
  8. // @description change or hide search results of Google & Bing
  9. // @include *.google.*
  10. // @include *www.bing.com/*
  11. // @namespace https://gf.qytechs.cn/scripts/2229
  12. // @homepageURL https://gf.qytechs.cn/scripts/2229
  13. // @run-at document-end
  14. // @grant GM_log
  15. // @grant GM_config
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_deleteValue
  19. // @grant GM_registerMenuCommand
  20. // ==/UserScript==
  21.  
  22.  
  23. /***************************************************************************************
  24. //require GreaseMonkey Script Configurator 1.2.57 //
  25. //Copyright: JoeSimmons & Sizzlemctwizzle & IzzySoft //
  26. //(c)https://gf.qytechs.cn/scripts/1884-gm-config //
  27. //license LGPL version 3 or any later version; http://www.gnu.org/copyleft/lgpl.html //
  28. ***************************************************************************************/
  29.  
  30.  
  31. /*=====================================================================================================================
  32. *************************************************************************
  33. ***注意:文字コードはUFT-8で保存してくださいNotice for 2byte Charactor ***
  34. *************************************************************************
  35.  
  36. ===解説(Read me)===
  37.  
  38. ・GoogleとBingの検索結果を非表示にする機能(Hide the search result by google or Bing)
  39. ・GoogleとBingの検索結果のURLを変更する機能(Change the search result's URL by google or Bing)
  40.  
  41.  
  42. [非表示について(about to hide)]-----------------------------------------------------------------------------
  43. ===例文For example===
  44. ex)"hogehoge"と"wiki"が両方共あって、"jp"か"com"のどちらともなかったら検索結果を消す
  45. (Hit "hogehoge" and "wiki" ,And still "jp" or "com" are not included.Hide result)
  46.  
  47. { NGword : ["hogehoge","wiki"], ignore : ["jp","com"]},
  48.  
  49. ===ヒント(hint)===
  50. ・項目は複数指定が可能(Items can be increased)
  51. ・NGwordはand条件です("NGword" is AND condition)
  52. ・ignoreはor条件です("ignore" is OR condition)
  53. ・""のように文字を指定しない場合は無視されます("" is ignored)
  54. ・日本語で検索できるので嫌いな単語が含まれたら消すことが出来ます。
  55. (Can search for Japanese)
  56.  
  57.  
  58. [URL置換について(about to change URL)]----------------------------------------------------------------------
  59. ===例文For example===
  60. ex)"www.hogehoge.com"を"hogehoge.com"にする
  61. (Change "www.hogehoge.com" to "hogehoge.com")
  62. { before : "www.hogehoge.com", after : "hogehoge.com" },
  63.  
  64. ex)"hogehoge"を消す
  65. (Delete "hogehoge")
  66. { before : "hogehoge", after : "" },
  67.  
  68. ex)"ぬるぽ"を"ガッ"にする
  69. (Change "ぬるぽ" to "ガッ". for 2byte charactor.)
  70. { before : "ぬるぽ", after : "ガッ" },
  71.  
  72. ===ヒント(hint)===
  73. ・項目は1つだけなので増やせません(Only one item. Can not be added)
  74. ・beforeは検索用のURLです("before" is search URL)
  75. ・afterは変換後のURLです("after" is changed URL)
  76. ・beforeで""のように文字を指定しない場合は無視されます("" is ignored in before)
  77. ・どちらも日本語で指定するとURL表記に変更されます。※パーセントエンコードします
  78. (2byte charactor is changed to the URL notation.for Japanese)
  79. ・もし検索条件を追加したいなら(If you would like to add a search condition.)
  80. ex:add ie=utf-8 @Google("http://www.google.com/search?num=50" to "http://www.google.com/search?ie=utf-8&num=50")
  81. { before : "search?", after : "search?ie=utf-8&" },
  82.  
  83.  
  84. ===注意事項(notice)===
  85. *************************************************************************
  86. 一番最後のカンマ(,)を忘れないこと(Do not forget the last comma)
  87. ・同じ単語を指定すると干渉する場合があります
  88. (If you specify the same word,May interfere)
  89. *************************************************************************
  90.  
  91. =====================================================================================================================*/
  92.  
  93. /*************************************************************************************************************
  94. 更新履歴
  95.  
  96. 11/30/2017 - v2.02 fix : 仕様変更対応
  97. 03/31/2015 - v2.01 fix : 重複していた処理の修正
  98. 02/11/2015 - v2.00 add : Simple format check
  99. 02/11/2015 - v2.00 add : bing
  100. 08/19/2014 - v1.15 add : close config when keydown ESC
  101. 08/19/2014 - v1.15 fix : config button
  102. 06/13/2014 - v1.14 del : @updateURL
  103. 06/12/2014 - v1.13 add : @grant & @homepageURL
  104. 06/07/2014 - v1.12 update : delete require. and include the code in script.
  105. 06/05/2014 - v1.11 fix : userscripts.org
  106. 05/17/2014 - v1.10 fix : userscripts.org:8080
  107. 03/14/2014 - v1.9 fix : Fixed [undefined] Error (GoogleSearchButton)
  108. 06/11/2013 - v1.8 fix : Fixed for Chrome
  109. 06/10/2013 - v1.7 fix : Fixed that did not work When logout
  110. 06/09/2013 - v1.6 fix : It corresponded to specification change of google.
  111. 04/06/2013 - v1.5 fix : The fault which will not operate if logged in to Google was corrected.
  112. 03/19/2013 - v1.4 update : For AutoPager & AutoPagerize.
  113. 03/09/2013 - v1.3 fix : Config window For Chrome
  114. 03/09/2013 - v1.2 add : GM_config
  115. 01/29/2013 - v1.1 add : check update
  116. 11/13/2011 - v1.0 release
  117.  
  118. **************************************************************************************************************/
  119.  
  120. /*************************************************************************************************************
  121. 備忘録
  122. ・以下をgreasyforkに変更
  123. http://www.userscripts.org/scripts/show/117908
  124. http://userscripts.org/scripts/source/117908.user.js
  125. ・@updateURLを削除(インストールしたときのサイトURLをアドオンが保持しているので更新可能な模様)
  126.  
  127. **************************************************************************************************************/
  128.  
  129.  
  130. //====================================================================================================================
  131.  
  132. (function(){
  133. if(window!=parent)return; //iframeは除外
  134. if(location.host.match("plus.google.com")) return;
  135.  
  136. var hideList = "";
  137. var changeList = "";
  138.  
  139.  
  140.  
  141. //ユーザーコンフィグ画面(GM_config)
  142. userCfg();
  143.  
  144. //メイン
  145. handle(document);
  146.  
  147.  
  148.  
  149. //プログラム部Main PG==================================================================================================
  150.  
  151. //非表示処理(Hide result)--------------------------------------------------------------------------
  152. function handle(node){
  153. if(!node.tagName && node != document) return
  154.  
  155. if(hideList == ""){ alert("format error : hideList"); return;}
  156. if(changeList == ""){ alert("format error : changeList"); return;}
  157.  
  158. var result_Hide = document.getElementsByTagName('li');
  159. if(node.tagName && node.tagName.match(/^li$/i)) result_Hide = [node];
  160.  
  161. for (i = 0; i < result_Hide.length; i++){
  162. var strTag = result_Hide[i]; //検索結果のテキスト情報(Search result)
  163. var hideFlg = 0; //非表示フラグ(Hide flag)
  164. //0:初期値(initial) 1:非表示(hide) 2:表示(visible)
  165.  
  166. for (j = 0; j < hideList.length; j++){
  167.  
  168. //非表示処理(Hide result)--------------------------------------------------
  169. for (k = 0; k < hideList[j].NGword.length; k++){
  170. if (hideList[j].NGword[k] == "" ){
  171. continue;
  172. }
  173.  
  174. if (strTag.className.match(/(g|gb_algo)/i) && strTag.innerHTML.match(hideList[j].NGword[k])){
  175. hideFlg = 1;
  176.  
  177. }else{
  178. hideFlg = 2;
  179. }
  180. }
  181.  
  182. //例外判定(Exception)------------------------------------------------------
  183. for (k = 0; k < hideList[j].ignore.length; k++){
  184. if (hideList[j].ignore[k] == "" ){
  185. continue;
  186. }
  187. if (strTag.className.match(/(g|gb_algo)/i) && strTag.innerHTML.match(hideList[j].ignore[k])){
  188. hideFlg = 2;
  189. //throw "test";//変数確認用
  190. }
  191. }
  192.  
  193. //検索結果削除(Delete result)----------------------------------------------
  194. if (hideFlg == 1){
  195. strTag.innerHTML = '';
  196. hideFlg = 0;
  197. strTag.setAttribute('style', 'display:none;');
  198. }
  199. }
  200. }
  201.  
  202.  
  203. //URL置換Change URL----------------------------------------------------------------------------------------
  204.  
  205. var result_Ch = document.evaluate('.//H3', node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) //google
  206. if(!result_Ch.snapshotLength)result_Ch = document.evaluate('.//H2', node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); //bing
  207.  
  208. for (i = 0; i < result_Ch.snapshotLength; i++){
  209.  
  210. for(j = 0; j < result_Ch.snapshotItem(i).getElementsByTagName('a').length; j++){
  211. var oldLink = result_Ch.snapshotItem(i).getElementsByTagName('a')[j].getAttribute('href'); //検索結果のURL(Original URL)
  212.  
  213. for (k = 0; k < changeList.length; k++){
  214. if (changeList[k].before == ""){
  215. continue;
  216. }
  217.  
  218. var newLink = oldLink.replace(encStr(changeList[k].before), encStr(changeList[k].after));
  219. //置換後のリンク(Changed URL)
  220.  
  221. if (newLink != oldLink){
  222.  
  223. result_Ch.snapshotItem(i).getElementsByTagName('a')[j].setAttribute('href', newLink);
  224.  
  225. }
  226. }
  227. }
  228. }
  229. }
  230.  
  231. //共通プログラムCommon PG=======================================================================================
  232.  
  233. //日本語をパーセントエンコードする(For Japanese encode)-------------------------------------
  234. function encStr( str ){
  235. var encodeString = encodeURI(str) ;
  236. return encodeString;
  237. }
  238.  
  239.  
  240. //ユーザー設定画面(userconfig)-------------------------------------------------------------
  241. function userCfg(){
  242.  
  243. //==============================================================
  244. //GreaseForkがrequireの審査必要なのでいっそのこと埋め込みました。
  245. //Copyright: JoeSimmons & Sizzlemctwizzle & IzzySoft
  246. //require (c)https://gf.qytechs.cn/scripts/1884-gm-config
  247. //==============================================================
  248.  
  249. //============================引用開始===================================
  250.  
  251. var GM_config = {
  252. storage: 'GM_config',
  253. init: function(){
  254. for(var i=0,l=arguments.length,arg; i<l; ++i) {
  255. arg=arguments[i];
  256. switch(typeof arg) {
  257. case 'object': for(var j in arg) {
  258. switch(j) {
  259. case "open": GM_config.onOpen=arg[j]; delete arg[j]; break; // called when frame is gone
  260. case "close": GM_config.onClose=arg[j]; delete arg[j]; break; // called when settings have been saved
  261. case "save": GM_config.onSave=arg[j]; delete arg[j]; break; // store the settings objects
  262. default: var settings = arg;
  263. }
  264. } break;
  265. case 'function': GM_config.onOpen = arg; break; // passing a bare function is set to open
  266. // could be custom CSS or the title string
  267. case 'string': if(arg.indexOf('{') !== -1 && arg.indexOf('}') !== -1) var css = arg;
  268. else GM_config.title = arg;
  269. break;
  270. }
  271. }
  272. if(!GM_config.title) GM_config.title = 'Settings - Anonymous Script'; // if title wasn't passed through init()
  273.  
  274. // give the script a unique saving ID for non-firefox browsers
  275. GM_config.storage = GM_config.title.replace(/\W+/g, "").toLowerCase();
  276.  
  277. var stored = GM_config.read(); // read the stored settings
  278. GM_config.passed_values = {};
  279. for(var i in settings) {
  280. GM_config.doSettingValue(settings, stored, i, null, false);
  281. if(settings[i].kids) for(var kid in settings[i].kids) GM_config.doSettingValue(settings, stored, kid, i, true);
  282. }
  283. GM_config.values = GM_config.passed_values;
  284. GM_config.settings = settings;
  285. if (css) GM_config.css.stylish = css;
  286. },
  287. open: function() {
  288. if(document.evaluate("//iframe[@id='GM_config']",document,null,9,null).singleNodeValue) return;
  289. // Create frame
  290. document.body.appendChild((GM_config.frame=GM_config.create('iframe',{id:'GM_config', style:'position: fixed; top: 0; left: 0; opacity: 0; display: none; z-index: 999999; width: 75%; height: 75%; max-height: 95%; max-width: 95%; border:3px ridge #000000; overflow: auto;'})));
  291. GM_config.frame.src = 'about:blank'; // In WebKit src cant be set until it is added to the page
  292. //Chromeだとallow-scriptsも必要(ただしそれやっちゃうと結局セキュリティダダ下がり)
  293. GM_config.frame.sandbox="allow-same-origin";
  294. GM_config.frame.addEventListener('load', function() {
  295. var obj = GM_config, doc = this.contentDocument, frameBody = doc.getElementsByTagName('body')[0], create=obj.create, settings=obj.settings, anch, secNo;
  296. obj.frame.contentDocument.getElementsByTagName('head')[0].appendChild(create('style',{type:'text/css',textContent:obj.css.basic + "\n\n" + obj.css.stylish}));
  297.  
  298. // Add header and title
  299. frameBody.appendChild(create('div', {id:'header',className:'config_header block center', innerHTML:obj.title}));
  300.  
  301. // Append elements
  302. anch = frameBody; // define frame body
  303. secNo = 0; // anchor to append elements
  304. for(var i in settings) {
  305. var type, field = settings[i], value = obj.values[i], section = (field.section ? field.section : ["Main Options"]),
  306. headerExists = doc.evaluate(".//div[@class='section_header_holder' and starts-with(@id, 'section_')]", frameBody, null, 9, null).singleNodeValue;
  307.  
  308. if(typeof field.section !== "undefined" || headerExists === null) {
  309. anch = frameBody.appendChild(create('div', {className:'section_header_holder', id:'section_'+secNo, kids:new Array(
  310. create('a', {className:'section_header center', href:"javascript:void(0);", id:'c_section_kids_'+secNo, textContent:section[0], onclick:function(){GM_config.toggle(this.id.substring(2));}}),
  311. create('div', {id:'section_kids_'+secNo, className:'section_kids', style:obj.getValue('section_kids_'+secNo, "")==""?"":"display: none;"})
  312. )}));
  313. if(section[1]) anch.appendChild(create('p', {className:'section_desc center',innerHTML:section[1]}));
  314. secNo++;
  315. }
  316. anch.childNodes[1].appendChild(GM_config.addToFrame(field, i, false));
  317. }
  318.  
  319. // Add save and close buttons
  320. frameBody.appendChild(obj.create('div', {id:'buttons_holder', kids:new Array(
  321. obj.create('button',{id:'saveBtn',textContent:'Save',title:'Save options and close window',className:'saveclose_buttons',onclick:function(){GM_config.close(true)}}),
  322. obj.create('button',{id:'cancelBtn', textContent:'Cancel',title:'Close window',className:'saveclose_buttons',onclick:function(){GM_config.close(false)}}),
  323. obj.create('div', {className:'reset_holder block', kids:new Array(
  324. obj.create('a',{id:'resetLink',textContent:'Restore to default',href:'#',title:'Restore settings to default configuration',className:'reset',onclick:obj.reset})
  325. )}))}));
  326.  
  327. obj.center(); // Show and center it
  328. window.addEventListener('resize', obj.center, false); // Center it on resize
  329. if (obj.onOpen) obj.onOpen(); // Call the open() callback function
  330. // Close frame on window close
  331. window.addEventListener('beforeunload', function(){GM_config.remove(this);}, false);
  332. }, false);
  333. },
  334. close: function(save) {
  335. if(save) {
  336. var type, fields = GM_config.settings, typewhite=/radio|text|hidden|password|checkbox/;
  337. for(f in fields) {
  338. var field = GM_config.frame.contentDocument.getElementById('field_'+f), kids=fields[f].kids;
  339. if(typewhite.test(field.type)) type=field.type;
  340. else type=field.tagName.toLowerCase();
  341. GM_config.doSave(f, field, type);
  342. if(kids) for(var kid in kids) {
  343. var field = GM_config.frame.contentDocument.getElementById('field_'+kid);
  344. if(typewhite.test(field.type)) type=field.type;
  345. else type=field.tagName.toLowerCase();
  346. GM_config.doSave(kid, field, type, f);
  347. }
  348. }
  349. if(GM_config.onSave) GM_config.onSave(); // Call the save() callback function
  350. GM_config.save();
  351. }
  352. if(GM_config.frame) GM_config.remove(GM_config.frame);
  353. delete GM_config.frame;
  354. if(GM_config.onClose) GM_config.onClose(); // Call the close() callback function
  355. },
  356. set: function(name,val) {
  357. GM_config.values[name] = val;
  358. },
  359. get: function(name) {
  360. return GM_config.values[name];
  361. },
  362. isGM: (typeof window.opera === "undefined" && typeof window.chrome === "undefined" && typeof GM_info === "object" && typeof GM_registerMenuCommand === "function"),
  363. log: function(str) {
  364.  
  365. if(this.isGM) return GM_log(str);
  366. else if(window.opera) return window.opera.postError(str);
  367. else return console.log(str);
  368.  
  369. },
  370. getValue : function(name, d) {
  371. var r, def = (typeof d !== "undefined" ? d : "");
  372. switch(this.isGM === true) {
  373. case true: r = GM_getValue(name, def); break;
  374. case false: r = localStorage.getItem(name) || def; GM_log("test:" + typeof GM_info); break;
  375. }
  376. return r;
  377. },
  378. setValue : function(name, value) {
  379. switch(this.isGM === true) {
  380. case true: GM_setValue(name, value); break;
  381. case false: localStorage.setItem(name, value); break;
  382. }
  383. },
  384. deleteValue : function(name) {
  385. switch(this.isGM === true) {
  386. case true: GM_deleteValue(name); break;
  387. case false: localStorage.removeItem(name); break;
  388. }
  389. },
  390. save: function(store, obj) {
  391. try {
  392. var val = JSON.stringify(obj || GM_config.values);
  393. GM_config.setValue((store||GM_config.storage),val);
  394. } catch(e) {
  395. GM_config.log("GM_config failed to save settings!\n" + e);
  396. }
  397. },
  398. read: function(store) {
  399. var val = GM_config.getValue((store || GM_config.storage), '{}');
  400. switch(typeof val) {
  401. case "string": var rval = JSON.parse(val); break;
  402. case "object": var rval = val; break;
  403. default: var rval = {};
  404. }
  405. return rval;
  406. },
  407. reset: function(e) {
  408. e.preventDefault();
  409. var type, obj = GM_config, fields = obj.settings;
  410. for(f in fields) {
  411. var field = obj.frame.contentDocument.getElementById('field_'+f), kids=fields[f].kids;
  412. if(field.type=='radio'||field.type=='text'||field.type=='checkbox') type=field.type;
  413. else type=field.tagName.toLowerCase();
  414. GM_config.doReset(field, type, null, f, null, false);
  415. if(kids) for(var kid in kids) {
  416. var field = GM_config.frame.contentDocument.getElementById('field_'+kid);
  417. if(field.type=='radio'||field.type=='text'||field.type=='checkbox') type=field.type;
  418. else type=field.tagName.toLowerCase();
  419. GM_config.doReset(field, type, f, kid, true);
  420. }
  421. }
  422. },
  423. addToFrame : function(field, i, k) {
  424. var elem, obj = this, anch = this.frame, value = obj.values[i], Options = field.options, label = field.label, create=obj.create, isKid = (k !== null && k === true);
  425. switch(field.type) {
  426. case 'textarea':
  427. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  428. create('span', {textContent:label, className:'field_label'}),
  429. create('textarea', {id:'field_'+i,innerHTML:value, cols:(field.cols?field.cols:20), rows:(field.rows?field.rows:2)})
  430. ), className: 'config_var'});
  431. break;
  432. case 'radio':
  433. var boxes = new Array();
  434. for (var j = 0,len = Options.length; j<len; j++) {
  435. boxes.push(create('span', {textContent:Options[j]}));
  436. boxes.push(create('input', {value:Options[j], type:'radio', name:i, checked:Options[j]==value?true:false}));
  437. }
  438. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  439. create('span', {textContent:label, className:'field_label'}),
  440. create('span', {id:'field_'+i, kids:boxes})
  441. ), className: 'config_var'});
  442. break;
  443. case 'select':
  444. var options = [];
  445. if(typeof Options === "object" && typeof Options.push !== "function") for(var j in Options) options.push(create('option',{textContent:Options[j],value:j,selected:(j==value)}));
  446. else options.push(create("option", {textContent:"Error - \"options\" needs to be a JSON object.", value:"error", selected:"selected"}));
  447. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  448. create('span', {textContent:label, className:'field_label'}),
  449. create('select',{id:'field_'+i, kids:options})
  450. ), className: 'config_var'});
  451. break;
  452. case 'checkbox':
  453. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  454. create('label', {textContent:label, className:'field_label', "for":'field_'+i}),
  455. create('input', {id:'field_'+i, type:'checkbox', value:value, checked:value})
  456. ), className: 'config_var'});
  457. break;
  458. case 'button':
  459. var tmp;
  460. elem = create(isKid ? "span" : "div", {kids:new Array(
  461. (tmp=create('input', {id:'field_'+i, type:'button', value:label, size:(field.size?field.size:25), title:field.title||''}))
  462. ), className: 'config_var'});
  463. if(field.script) obj.addEvent(tmp, 'click', field.script);
  464. break;
  465. case 'hidden':
  466. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  467. create('input', {id:'field_'+i, type:'hidden', value:value})
  468. ), className: 'config_var'});
  469. break;
  470. case 'password':
  471. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  472. create('span', {textContent:label, className:'field_label'}),
  473. create('input', {id:'field_'+i, type:'password', value:value, size:(field.size?field.size:25)})
  474. ), className: 'config_var'});
  475. break;
  476. default:
  477. elem = create(isKid ? "span" : "div", {title:field.title||'', kids:new Array(
  478. create('span', {textContent:label, className:'field_label'}),
  479. create('input', {id:'field_'+i, type:'text', value:value, size:(field.size?field.size:25)})
  480. ), className: 'config_var'});
  481. }
  482. if(field.kids) {
  483. var kids=field.kids;
  484. for(var kid in kids) elem.appendChild(obj.addToFrame(kids[kid], kid, true));
  485. }
  486. return elem;
  487. },
  488. doSave : function(f, field, type, oldf) {
  489. var isNum=/^[\d\.]+$/, set = oldf ? GM_config.settings[oldf]["kids"] : GM_config.settings;
  490. switch(type) {
  491. case 'text':
  492. GM_config.values[f] = ((set[f].type=='text') ? field.value : ((isNum.test(field.value) && ",int,float".indexOf(","+set[f].type)!=-1) ? parseFloat(field.value) : false));
  493. if(set[f]===false) {
  494. alert('Invalid type for field: '+f+'\nPlease use type: '+set[f].type);
  495. return;
  496. }
  497. break;
  498. case 'hidden': case 'password':
  499. GM_config.values[f] = field.value.toString();
  500. break;
  501. case 'textarea':
  502. GM_config.values[f] = field.value;
  503. break;
  504. case 'checkbox':
  505. GM_config.values[f] = field.checked;
  506. break;
  507. case 'select':
  508. GM_config.values[f] = field.options[field.selectedIndex].value;
  509. break;
  510. case 'span':
  511. var radios = field.getElementsByTagName('input');
  512. if(radios.length>0) for(var i=radios.length-1; i>=0; i--) {
  513. if(radios[i].checked) GM_config.values[f] = radios[i].value;
  514. }
  515. break;
  516. }
  517. },
  518. doSettingValue : function(settings, stored, i, oldi, k) {
  519. var set = k!=null && k==true && oldi!=null ? settings[oldi]["kids"][i] : settings[i];
  520. if(",save,open,close".indexOf(","+i) == -1) {
  521. // The code below translates to:
  522. // if a setting was passed to init but wasn't stored then
  523. // if a default value wasn't passed through init() then use null
  524. // else use the default value passed through init()
  525. // else use the stored value
  526. try {
  527. var value = (stored[i]==undefined ? (set["default"]==undefined ? null : set["default"]) : stored[i]);
  528. } catch(e) {
  529. var value = (stored[i]=="undefined" ? (set["default"]=="undefined" ? null : set["default"]) : stored[i]);
  530. }
  531. // If the value isn't stored and no default was passed through init()
  532. // try to predict a default value based on the type
  533. if (value === null) {
  534. switch(set["type"]) {
  535. case 'radio': case 'select':
  536. value = set.options[0]; break;
  537. case 'checkbox':
  538. value = false; break;
  539. case 'int': case 'float':
  540. value = 0; break;
  541. default:
  542. value = (typeof stored[i]=="function") ? stored[i] : "";
  543. }
  544. }
  545. }
  546. GM_config.passed_values[i] = value;
  547. },
  548. doReset : function(field, type, oldf, f, k) {
  549. var isKid = k!=null && k==true, obj=GM_config,
  550. set = isKid ? obj.settings[oldf]["kids"][f] : obj.settings[f];
  551. switch(type) {
  552. case 'text':
  553. field.value = set['default'] || '';
  554. break;
  555. case 'hidden': case 'password':
  556. field.value = set['default'] || '';
  557. break;
  558. case 'textarea':
  559. field.value = set['default'] || '';
  560. break;
  561. case 'checkbox':
  562. field.checked = set['default'] || false;
  563. break;
  564. case 'select':
  565. if(set['default']) {
  566. for(var i=field.options.length-1; i>=0; i--)
  567. if(field.options[i].value==set['default']) field.selectedIndex=i;
  568. }
  569. else field.selectedIndex=0;
  570. break;
  571. case 'span':
  572. var radios = field.getElementsByTagName('input');
  573. if(radios.length>0) for(var i=radios.length-1; i>=0; i--) {
  574. if(radios[i].value==set['default']) {
  575. radios[i].checked=true;
  576. }
  577. }
  578. break;
  579. }
  580. },
  581. values: {},
  582. settings: {},
  583. css: {
  584. basic: 'body {background:#FFFFFF;}\n' +
  585. '.indent40 {margin-left:40%;}\n' +
  586. '* {font-family: arial, tahoma, sans-serif, myriad pro;}\n' +
  587. '.field_label {font-weight:bold; font-size:12px; margin-right:6px;}\n' +
  588. '.block {display:block;}\n' +
  589. '.saveclose_buttons {\n' +
  590. 'margin:16px 10px 10px 10px;\n' +
  591. 'padding:2px 12px 2px 12px;\n' +
  592. '}\n' +
  593. '.reset, #buttons_holder, .reset a {text-align:right; color:#000000;}\n' +
  594. '.config_header {font-size:20pt; margin:0;}\n' +
  595. '.config_desc, .section_desc, .reset {font-size:9pt;}\n' +
  596. '.center {text-align:center;}\n' +
  597. '.section_header_holder {margin-top:8px;}\n' +
  598. '.config_var {margin:0 0 4px 0; display:block;}\n' +
  599. '.config_var {font-size: 13px !important;}\n' +
  600. '.section_header {font-size:13pt; background:#414141; color:#FFFFFF; border:1px solid #000000; margin:0;}\n' +
  601. '.section_desc {font-size:9pt; background:#EFEFEF; color:#575757; border:1px solid #CCCCCC; margin:0 0 6px 0;}\n' +
  602. 'input[type="radio"] {margin-right:8px;}',
  603. stylish: ''
  604. },
  605. create: function(a,b) {
  606. var ret=window.document.createElement(a);
  607. if(b) for(var prop in b) {
  608. if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false);
  609. else if(prop=="kids" && (prop=b[prop])) for(var i=0; i<prop.length; i++) ret.appendChild(prop[i]);
  610. else if(",style,accesskey,id,name,src,href,for".indexOf(","+prop.toLowerCase())!=-1) ret.setAttribute(prop, b[prop]);
  611. else ret[prop]=b[prop];
  612. }
  613. return ret;
  614. },
  615. center: function() {
  616. var node = GM_config.frame, style = node.style, beforeOpacity = style.opacity;
  617. if(style.display=='none') style.opacity='0';
  618. style.display = '';
  619. style.top = Math.floor((window.innerHeight/2)-(node.offsetHeight/2)) + 'px';
  620. style.left = Math.floor((window.innerWidth/2)-(node.offsetWidth/2)) + 'px';
  621. style.opacity = '1';
  622. },
  623. run: function() {
  624. var script=GM_config.getAttribute('script');
  625. if(script && typeof script=='string' && script!='') {
  626. func = new Function(script);
  627. window.setTimeout(func, 0);
  628. }
  629. },
  630. addEvent: function(el, ev, scr) {
  631. if(el) el.addEventListener(ev, function() {
  632. typeof scr === 'function' ? window.setTimeout(scr, 0) : eval(scr)
  633. }, false);
  634. },
  635. remove: function(el) {
  636. if(el && el.parentNode) el.parentNode.removeChild(el);
  637. },
  638. toggle : function(e) {
  639. var node=GM_config.frame.contentDocument.getElementById(e);
  640. node.style.display=(node.style.display!='none')?'none':'';
  641. GM_config.setValue(e, node.style.display);
  642. },
  643. };
  644.  
  645.  
  646. //============================引用ここまで===================================
  647.  
  648.  
  649.  
  650. //ユーザー設定(User's settings)-------------------------------------------------------------------------------------
  651.  
  652. //検索ボタンの横に設定ボタン追加(Add Config Button beside search button)
  653. var searchBtn = document.getElementsByName("btnG")[0] //google
  654. || document.getElementsByClassName("b_searchboxForm")[0]; //bing
  655.  
  656. if(searchBtn){
  657. if(location.hostname.match(/bing.com/)) tmpTxt = "top:0px;left:10px;";
  658. //FirefoxとChromeの表示方式対応(もしかしたら新仕様CSSと変更前の旧仕様CSSの違いかもしれない)
  659. //Firefox側
  660. else if(document.getElementById("sblsbb") != null) tmpTxt = "top:-8px;left:30px;";
  661. else if(searchBtn.className == "sbico-c"){
  662. searchBtn = document.getElementById("sfdiv");
  663. tmpTxt = "top:-25px;right:-20px;float:right;";
  664. //Chrome側(旧仕様)
  665. }else tmpTxt = "top:8px;left:3px;";
  666.  
  667. searchBtn.insertAdjacentHTML('afterend','<img name="setBtn" id="setBtn" type="button" style="position:relative;' + tmpTxt + '" '
  668. + 'src="data:image/gif;base64,R0lGODlhCwALAIABAACZ/////yH5BAEAAAEALAAAAAALAAsAAAIaBHKha6j5TmrRIdqmkTLu7HHWVmlMZ5XLWgAAOw==" '
  669. + 'title="Config - Change search result for Google and Bing">');
  670.  
  671.  
  672. //設定ボタンクリックで設定画面を呼び出す(Open Config Window,when click the Config Button)
  673. var setBtn = document.getElementById("setBtn");
  674. setBtn.addEventListener('click', function(){GM_config.open()}, true);
  675.  
  676. }else{
  677. GM_log("CSR_Error:検索Buttonが見つからない")
  678. }
  679.  
  680.  
  681. //設定画面(Config Window)
  682. GM_config.init('Config - Change search result for Google' /* Script title */,
  683. /* Settings object */
  684. {
  685. 'hideList': // This would be accessed using GM_config.get('Name')
  686. {
  687. 'section': ['hideList'],
  688. 'label': '{ NGword : ["word1","word2","word3","word...more"], ignore : ["word4","word5","word...more"] },', // Appears next to field
  689. 'type': 'textarea', // Makes this setting a text field
  690. cols: 120,
  691. rows: 10,
  692. 'default': '{ NGword : ["","","",""], ignore : ["",""] },\n'
  693. + '{ NGword : ["",""], ignore : ["","",""] },\n'
  694. + '{ NGword : [""], ignore : [""] },\n'
  695. + '{ NGword : ["","",""], ignore : ["",""] },\n'
  696. + '{ NGword : [""], ignore : ["","","","",""] },\n' // Default value if user doesn't change it
  697. },
  698. 'changeList': // This would be accessed using GM_config.get('Name')
  699. {
  700. 'section': ['changeList'],
  701. 'label': '{ before : "beforeURL", after : "afterURL" },', // Appears next to field
  702. 'type': 'textarea', // Makes this setting a text field
  703. cols: 120,
  704. rows: 10,
  705. 'default': '{ before : "scribe.twitter.com", after : "twitter.com" }, //Twitterの表示されないURL(Delete scribe)\n'
  706. + '{ before : "zxbtapi.appspot.com", after : "twitter.com" }, //appspot回避(Avoid appspot)\n'
  707. + '{ before : "", after : "" },\n'
  708. + '{ before : "", after : "" },\n'
  709. + '{ before : "", after : "" },\n' // Default value if user doesn't change it
  710. }
  711. },
  712. /* chrome非対応のため削除(Delete :this CSS do not work on Chrome)******************************************:
  713. '.section_header_holder{height:33%;width:80%;}' + //枠
  714. '#section_1{padding-top:50px;}' + //changeListの枠
  715. '.section_header.center{background:aliceblue!important;color:black;pointer-events: none;border:none;}' + //タイトル
  716. '#field_hideList{height:100%;width:100%;resize: none;}' + //hideListテキスト
  717. '#field_changeList{height:100%;width:100%;resize: none;}' + //changeListテキスト
  718. '#buttons_holder{width:20%;position:absolute;bottom:10%;right:10px;}', + //セーブ・キャンセル・リセットボタン
  719. ***************************************************************************************/
  720. {
  721. open: function() {
  722. //config window
  723. var cfg_Window = document.getElementById("GM_config");
  724. //リスト全部(list section)=================================================
  725. var cfg_hideSection = cfg_Window.contentDocument.getElementById("section_0"); //hideList
  726. var cfg_changeSection = cfg_Window.contentDocument.getElementById("section_1"); //changeList
  727.  
  728. cfg_hideSection.setAttribute("style", "height:33%;width:80%;");
  729. cfg_changeSection.setAttribute("style", "height:33%;width:80%;padding-top:50px;");
  730. //section label============================================================
  731. var cfg_hideLabel = cfg_Window.contentDocument.getElementById("c_section_kids_0"); //hideList
  732. var cfg_changeLabel = cfg_Window.contentDocument.getElementById("c_section_kids_1"); //changeList
  733. cfg_hideLabel.setAttribute("style", "background:aliceblue!important;color:black;pointer-events: none;border:none;");
  734. cfg_changeLabel.setAttribute("style", "background:aliceblue!important;color:black;pointer-events: none;border:none;");
  735.  
  736. //textarea=================================================================
  737. var cfg_hideTxt = cfg_Window.contentDocument.getElementById("field_hideList"); //hideList
  738. var cfg_changeTxt = cfg_Window.contentDocument.getElementById("field_changeList"); //changeList
  739.  
  740. //改行無効化
  741. cfg_hideTxt.setAttribute("wrap", "off");
  742. cfg_changeTxt.setAttribute("wrap", "off");
  743.  
  744. //css
  745. cfg_hideTxt.setAttribute("style", "height:100%;width:100%;resize: none;");
  746. cfg_changeTxt.setAttribute("style", "height:100%;width:100%;resize: none;");
  747.  
  748. //save cancel==============================================================
  749. var cfg_buttonsHolder = cfg_Window.contentDocument.getElementById("buttons_holder");
  750. cfg_buttonsHolder.setAttribute("style", "width:20%;position:absolute;bottom:10%;right:10px;");
  751.  
  752.  
  753. var cfg_body = cfg_Window.contentDocument.getElementsByTagName("body")[0];
  754. cfgClose(document);
  755. cfgClose(cfg_body);
  756.  
  757. //ESC押したら設定画面閉じる
  758. function cfgClose(doc){
  759. try{
  760. doc.onkeydown = function(evt){
  761.  
  762. if (evt){
  763. var kc = evt.keyCode;
  764. }else{
  765. var kc = event.keyCode;
  766. }
  767. //GM_log(kc);
  768. if(kc!=27){ return; }
  769. GM_config.close();
  770. }
  771.  
  772. }catch(e){
  773. GM_log("CSR_escClose:"+e);
  774. }
  775. }//cfgCloseここまで
  776.  
  777.  
  778. }
  779. });
  780.  
  781.  
  782. var cssTxt = '#GM_config{height:100%!important;width:100%!important;z-index:1000!important;}';
  783.  
  784. addCSS(cssTxt);
  785.  
  786.  
  787. //GreaseMonkeyとScriptishのオプション追加(add Option)
  788. GM_registerMenuCommand("Config - Change search result for Google", GM_config.open);
  789.  
  790.  
  791. //変数取得(get variable)
  792. var hideListSaved = GM_config.get("hideList");
  793. var changeListSaved = GM_config.get("changeList");
  794.  
  795. //alert(GM_config.get("hideList"));
  796. //alert(GM_config.get("changeList"));
  797.  
  798.  
  799. //最終カンマ削除(delete last comma)
  800. do{
  801. hideListSaved = hideListSaved.slice(0, -1);
  802. //alert(hideListSaved.slice(-1));
  803.  
  804. }while(hideListSaved.slice(-1) != '}');
  805. do{
  806. changeListSaved = changeListSaved.slice(0, -1);
  807. //alert(changeListSaved.slice(-1));
  808.  
  809. }while(changeListSaved.slice(-1) != '}');
  810.  
  811. //alert(hideListSaved);
  812. //alert(changeListSaved);
  813.  
  814. try{
  815. //変数セット(set variable)
  816. hideList = eval("[" + hideListSaved + "]");
  817. changeList = eval("[" + changeListSaved + "]");
  818.  
  819. }catch(e){
  820. GM_log("CSR_変数error" +e);
  821. return;
  822. }
  823.  
  824. /*********************** GM_config以前の設定 ***************
  825.  
  826. //非表示リスト(Hide result LIST)--------------------------------------------------------------------
  827. var hideList = [
  828. { NGword : ["",""], ignore : ["",""]},
  829.  
  830. //以下に追加(Add Location start)**********************************************************************
  831.  
  832. { NGword : ["","","",""], ignore : ["",""] }, //追加サンプル(sample)
  833. { NGword : [""], ignore : ["","",""] }, //追加サンプル(sample)
  834. { NGword : [""], ignore : [""] }, //追加サンプル(sample)
  835. { NGword : ["",""], ignore : ["",""] }, //追加サンプル(sample)
  836. { NGword : ["",""], ignore : ["",""] }, //追加サンプル(sample)
  837.  
  838. //上に追加(Add Location end)**************************************************************************
  839.  
  840. { NGword : ["",""], ignore : ["",""]}
  841. ];
  842.  
  843. //変換リスト(Change URL LIST)----------------------------------------------------------------------
  844. var changeList = [
  845. { before : "scribe.twitter.com", after : "twitter.com" }, //Twitterの表示されないURL(Delete scribe)
  846.  
  847. //以下に追加(Add Location start)**********************************************************************
  848.  
  849. { before : "zxbtapi.appspot.com", after : "twitter.com" }, //appspot回避(Avoid appspot)
  850. { before : "", after : "" }, //追加サンプル(sample)
  851. { before : "", after : "" }, //追加サンプル(sample)
  852. { before : "", after : "" }, //追加サンプル(sample)
  853.  
  854. //上に追加(Add Location end)**************************************************************************
  855. { before : "", after : "" } //追加サンプル(sample)
  856.  
  857. ];
  858.  
  859. //ユーザ設定から読み込み(Load user's settings)
  860. var hideListSaved = eval( GM_getValue("hideList"));
  861. var changeListSaved = eval( GM_getValue("changeList"));
  862.  
  863. //ユーザー設定を保存(Save user's settings)
  864. if(hideList != hideListSaved){
  865. GM_setValue( "hideList", hideList.toSource() );
  866. }
  867. if(changeList != changeListSaved){
  868. GM_setValue( "changeList", changeList.toSource() );
  869. }
  870. ************************************************************/
  871.  
  872. }
  873.  
  874.  
  875.  
  876.  
  877. //For Chrome:Change "GM_setValue & GM_getValue" to WebStrage-------------------------------------------
  878. if (!this.GM_getValue) {
  879. this.GM_getValue=function (key,def) {
  880. return window.localStorage.getItem(key);
  881. };
  882. this.GM_setValue=function (key,value) {
  883. return window.localStorage.setItem(key, value);
  884. };
  885. }
  886.  
  887. //css追加
  888. function addCSS(css){
  889. var head = document.getElementsByTagName('head');
  890. if(!head) return;
  891. else head = head[0];
  892.  
  893. var style = document.createElement('style');
  894. style.type = 'text/css';
  895. style.innerHTML = css;
  896.  
  897. head.appendChild(style);
  898. }
  899.  
  900. //For AutoPagerize-----------------------------------------------------------------------------------
  901. document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt){
  902. var node = evt.target;
  903. handle(node);
  904. }, false);
  905. //For AutoPager--------------------------------------------------------------------------------------
  906. document.body.addEventListener('AutoPagerAfterInsert', function(evt){
  907. var node = evt.target;
  908. handle(node);
  909. }, false);
  910. //For AutoPatchWork----------------------------------------------------------------------------------
  911. document.body.addEventListener('AutoPatchWork.DOMNodeInserted', function(evt){
  912. var node = evt.target;
  913. handle(node);
  914. }, false);
  915.  
  916.  
  917. })();
  918. //=====================================================================================================================

QingJ © 2025

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