Change search result for Google

change or hide search results of google

当前为 2014-06-12 提交的版本,查看 最新版本

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

QingJ © 2025

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