dealextreme diary
@@ -4,18 +4,31 @@
* @include http://*
* @license DX License
*/
-(function(){
-var hatenaid = window.prompt('input hatena id', '');
-var meta = document.getElementsByTagName('meta');
-var imgurl;
-for(var i = 0; i < meta.length; i++)
-{
- if (meta[i].hasAttribute('property') && meta[i].getAttribute('property') == "og:image")
- {
- imgurl = meta[i].getAttribute('content');
- break;
- }
-}
-var ebody = "[" + location.href + ":title]\r\n["+ imgurl +":image]";
-location.href = "http://dealextreme.g.hatena.ne.jp/" + hatenaid + "/?appendbody=" + encodeURIComponent(ebody) + "#edit_in_place";
+(function () {
+ var hatenaid = localStorage.getItem('hatenaid');
+ if (!hatenaid) {
+ hatenaid = window.prompt('input hatena id', '');
+ localStorage.setItem('hatenaid', hatenaid);
+ }
+ var meta = document.getElementsByTagName('meta');
+ var imgurl;
+ for (var i=0;i<meta.length;i++) {
+ if(
+ meta[i].hasAttribute('property')
+ && meta[i].getAttribute('property') == "og:image"
+ ) {
+ imgurl = meta[i].getAttribute('content');
+ break;
+ }
+ }
+ var ebody = "**[" +
+ location.href +
+ ":title]\r\n[" +
+ imgurl.replace(/\_small\.jpg/, '.jpg') +
+ ":image]";
+ location.href = "http://dealextreme.g.hatena.ne.jp/" +
+ hatenaid +
+ "/?appendbody=" +
+ encodeURIComponent(ebody) +
+ "#edit_in_place";
})();
/*
* @title dealextreme diary
* @description dealextreme toukou shimasu
* @include http://*
* @license DX License
*/
(function () {
var hatenaid = localStorage.getItem('hatenaid');
if (!hatenaid) {
hatenaid = window.prompt('input hatena id', '');
localStorage.setItem('hatenaid', hatenaid);
}
var meta = document.getElementsByTagName('meta');
var imgurl;
for (var i=0;i<meta.length;i++) {
if(
meta[i].hasAttribute('property')
&& meta[i].getAttribute('property') == "og:image"
) {
imgurl = meta[i].getAttribute('content');
break;
}
}
var ebody = "**[" +
location.href +
":title]\r\n[" +
imgurl.replace(/\_small\.jpg/, '.jpg') +
":image]";
location.href = "http://dealextreme.g.hatena.ne.jp/" +
hatenaid +
"/?appendbody=" +
encodeURIComponent(ebody) +
"#edit_in_place";
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。