Hatena::Let にサイト内検索を追加 (DuckDuckGo)
@@ -1,33 +1,22 @@
/*
- * @title Hatena::Letにサイト内検索を追加
- * @description これで車輪の再発明を防げる?
+ * @title Hatena::Let にサイト内検索を追加 (DuckDuckGo)
+ * @description Google だと引っかからないページが割とあるみたいです。
* @include http://let.hatelabo.jp/*
* @license MIT License
- * @require
+ * @javascript_url
*/
-var frm = '\
-<!-- SiteSearch Google --> \
-<form method=get action="http://www.google.co.jp/search" target="_blank" style="display:inline"> \
-<a href="http://www.google.co.jp/"> \
-<img src="http://www.google.com/logos/Logo_40wht.gif" \
-border="0" alt="Google" align="absmiddle" style="height:30px;"></a> \
-<input type=text name=q size=31 maxlength=255 value=""> \
-<input type=hidden name=ie value=UTF-8> \
-<input type=hidden name=oe value=UTF-8> \
-<input type=hidden name=hl value="ja"> \
-<input type=submit name=btnG value="Google 検索"> \
-<font size=-1> \
-<input type=hidden name=domains value="YOURSITE.CO.JP"> \
-<input type=hidden name=sitesearch value="YOURSITE.CO.JP"> \
-</font> \
-</form> \
-<!-- SiteSearch Google --> \
-';
+(() => {
+ const i = document.body.appendChild(document.createElement('iframe'));
+ document.getElementById('logo').appendChild(i);
+ document.getElementById('simple-header').style.height = '40px';
+ i.style.cssText = 'overflow:hidden;margin:0;padding:0;border:0;width:360px;height:40px;';
+ i.src = 'https://duckduckgo.com/search.html?site=let.hatelabo.jp&prefill=f:htm ';
+})();
-var yoursiteAddr = 'let.hatelabo.jp';
-
-var myFrm = frm.replace(/YOURSITE.CO.JP/g, yoursiteAddr);
-
-var logoEl = document.getElementById('logo');
-logoEl.innerHTML += myFrm;
+/*
+経緯: http://ptech.g.hatena.ne.jp/noromanba/20170210/1486677295
+参考: https://duckduckgo.com/search_box
+prefill に指定した文字列は、最初 placeholder じゃなく value に入ってて、クリックすると消える。
+なので、クリックしないでフォーカスしてコピー (右クリックして「すべて選択」を選んで Ctrl + C とか) すると、検索の際にペーストして使える。
+*/
/*
* @title Hatena::Let にサイト内検索を追加 (DuckDuckGo)
* @description Google だと引っかからないページが割とあるみたいです。
* @include http://let.hatelabo.jp/*
* @license MIT License
* @javascript_url
*/
(() => {
const i = document.body.appendChild(document.createElement('iframe'));
document.getElementById('logo').appendChild(i);
document.getElementById('simple-header').style.height = '40px';
i.style.cssText = 'overflow:hidden;margin:0;padding:0;border:0;width:360px;height:40px;';
i.src = 'https://duckduckgo.com/search.html?site=let.hatelabo.jp&prefill=f:htm ';
})();
/*
経緯: http://ptech.g.hatena.ne.jp/noromanba/20170210/1486677295
参考: https://duckduckgo.com/search_box
prefill に指定した文字列は、最初 placeholder じゃなく value に入ってて、クリックすると消える。
なので、クリックしないでフォーカスしてコピー (右クリックして「すべて選択」を選んで Ctrl + C とか) すると、検索の際にペーストして使える。
*/
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。