greasemonkey:google-search-date-limiter

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
最新のリビジョン両方とも次のリビジョン
greasemonkey:google-search-date-limiter [2011/06/30 21:41] – userscripts.orgへ移行 dgbadmingreasemonkey:google-search-date-limiter [2014/08/24 22:40] – 0.7.0 dgbadmin
行 5: 行 5:
  
 ===== 使い方 ===== ===== 使い方 =====
-インストールすると、テキストボックスと検索ボタンの間に期間を指定する選択リスト(ドロップダウンリスト)が表示される\\+インストールすると、テキストボックスと検索ボタンの間に期間を指定する選択リスト(ドロップダウンリスト)が表示される 
 {{:javascript:google-search-result.jpg|}} {{:javascript:google-search-result.jpg|}}
 +
 ※この画面イメージは古いGoogle検索のときのもの ※この画面イメージは古いGoogle検索のときのもの
  
行 17: 行 19:
  
 ===== ダウンロード・インストール ===== ===== ダウンロード・インストール =====
-[[http://userscripts.org/scripts/show/105822|userscripts.org]]からどうぞ。+[[https://0-oo.googlecode.com/svn/trunk/us/google_search_date_limiter.user.js|Google Code]]からどうぞ。 
 + 
 + 
 +===== ソースコード ===== 
 +<code javascript> 
 +// ==UserScript== 
 +// @name        Google search date limiter 
 +// @namespace   http://0-oo.net/ 
 +// @description Add the date-range selector on Google Search. 
 +// @homepage    http://0-oo.net/log/category/javascript/google-search-date-limiter/ 
 +// @version     0.7.0 
 +// @grant       none 
 +// @include     http*://www.google.tld/search* 
 +// @include     http*://www.google.tld/webhp* 
 +// @include     http*://www.google.tld/imghp 
 +// @include     http*://www.google.tld/ig* 
 +// @include     http*://www.google.tld/#
 +// @include     http*://www.google.tld/ 
 +// ==/UserScript== 
 +// 
 +// ( The MIT License ) 
 +// 
 +setInterval(function() { 
 + if (document.getElementsByTagName("SELECT").length) { //消えたらまた追加する 
 + return; 
 +
 +     
 + var btn = document.getElementsByName("btnG")[0]; 
 +  
 + if (!btn) { 
 + return; 
 +
 +  
 + var btnDiv = btn.parentNode.parentNode; //検索ボタンを含むdiv 
 + btnDiv.setAttribute("style", "white-space:nowrap"); 
 +  
 + //(あれば)指定された期間 
 + var selected = decodeURIComponent(location.search).match(/tbs=qdr:([a-z])([0-9]+)/) || []; 
 +  
 + //数字のselect 
 + var selNum = document.createElement("select"); 
 + selNum.appendChild(document.createElement("option")); 
 +  
 + for (var i = 1; i < 60;) { 
 + var opt = document.createElement("option"); 
 + opt.appendChild(document.createTextNode(i)); 
 +  
 + if (i == selected[2]) { 
 + opt.selected = true; 
 +
 +  
 + selNum.appendChild(opt); 
 +  
 + if (i < 10) { 
 + i++; 
 + } else { 
 + i += 10; //10以上は10ずつ増加 
 +
 +
 +  
 + btnDiv.appendChild(selNum); 
 +  
 + //単位のselect 
 + var selUnit = document.createElement("select"); 
 + var units = {}, suffix = ""; 
 +  
 + if (navigator.language == "ja") { 
 + units = { s: "秒", n: "分", h: "時間", d: "日", w: "週間", m: "ヶ月", y: "年" }; 
 + suffix = " 以内"; 
 + } else { 
 +  units = { s: "second", n: "minute", h: "hour", d: "day", w: "week", m: "month", y: "year" }; 
 + suffix = "(s)"; 
 +
 +  
 + for (var val in units) { 
 + opt = document.createElement("option"); 
 + opt.setAttribute("value", val); 
 + opt.appendChild(document.createTextNode(units[val] + suffix)); 
 +  
 + if (val == selected[1]) { 
 + opt.selected = true; 
 +
 +  
 + selUnit.appendChild(opt); 
 +
 +  
 + if (!selected[1]) { 
 + selUnit.selectedIndex = 5; //デフォルトは"月" 
 +
 +  
 + btnDiv.appendChild(selUnit); 
 +  
 + btn.addEventListener("click", function() { 
 + var url = "/search?q="; 
 +  
 + //検索ワード 
 + url += encodeURIComponent(document.getElementsByName("q")[0].value); 
 +  
 + if (selNum.selectedIndex) { 
 + //期間 
 + var qdr = "qdr:" + selUnit.options[selUnit.selectedIndex].value; 
 + qdr += selNum.options[selNum.selectedIndex].text; 
 + url += "&tbs=" + qdr; 
 +
 +  
 + //(あれば)検索種類(画像検索等) 
 + url += location.href.match(/&tbm=[a-z]+/) || ""; 
 +  
 + //(あれば)表示言語 
 + url += location.href.match(/&hl=[-a-z]+/i) || ""; 
 +  
 + //(あれば)言語での絞り込み 
 + url += location.href.match(/&lr=lang_[-a-z]+/i) || ""; 
 +  
 + location.href = url; 
 + }, true); 
 +}, 10);  //レンダリング後のタイミングを見計らう 
 +</code> 
greasemonkey/google-search-date-limiter.txt · 最終更新: 2015/09/19 21:14 by dgbadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki