éçºè
æ§åã çªçµè¡¨ã«å¥½ããªãã®ã表示ãã¦ã¿ãã
ãçªçµè¡¨ã«ãã¤ãã¯ã·ã£æ¥è¨ã表示ããã¹ã¯ãªããããå°ãæ¹é ããã ãã§ãçªçµè¡¨ã«å¥½ããªãã®ã表示ããæ¹æ³ãç´¹ä»ãã¾ãã
ã¨ã¦ãç°¡åãªä¾ã§ã³ã¼ããæ¸ãã¦ã¿ã¾ãããã
ããªãã¯ããã¤ã®æéãã¨ã¦ã楽ãã¿ã§ãã©ããã¦ãçªçµè¡¨ã® 15:00 ã®æ¬ã«ãããã¤ã¡ãã»ã¼ã¸ã表示ãããã¨ãã¾ãããã
ãã®å ´åã®æé ã説æãã¦ããã¾ãã
ã¾ãã¯éåã¨ãªããHatenaRssMixiMix.user.jsããã¦ã³ãã¼ããã¾ãã
ããã¦ãã¡ã¤ã«ã®ååãå¤æ´ãã¾ãã
ããã§ã¯ãHatenaRssOyatsuMix.user.jsãã¨å¤æ´ãã¾ããã
ãã¡ã¤ã«åã®æ«å°¾ã®.user.jsã®é¨åã¯å¤æ´ããªãããã«æ³¨æãã¦ãã ããã
2.ã³ã¼ããæ¸ã
å®éã«ã³ã¼ãããæ°ã«å
¥ãã®ã¨ãã£ã¿(Emacs)ã§éãã¦ç·¨éããã¾ãã
ã¾ãã¯ããããã«ãã@nameã¨ããå±æ§ãæ¸ãæãã¾ãã
ããã¯ã¤ã³ã¹ãã¼ã«ã®éã«ä½¿ãããååãªã®ã§ãæ¢åã®ãã®ã¨ååãåãã«ãªããªãããã«ãã¦ä¸ããã
次ã«ãããã®ããä¸ãããã«ãã function fetchArticles() ã®ä¸èº«ã空ã«ãã¾ãã
ããã¦ããã«èªåã®ã³ã¼ãã追å ãã¦ããã¾ããï¼å¤ãã®å ´åããã®é¢æ°ä»¥å¤ã¯ãããå¿
è¦ã¯ããã¾ãããï¼
function fetchArticles() {
}
ã§ã¯æ©éã³ã¼ããæ¸ãã¦ããã¾ãããã
çªçµè¡¨ã«è¿½å ãããè¨äºï¼articleï¼ãã®ãªãã¸ã§ã¯ããä½ãã¾ãã
var article = createArticle();
article.url = 'http://d.hatena.ne.jp/keyworddiary/%a4%aa%a4%e4%a4%c4';
article.title = 'It is time for sweets.';
article.sitetitle = '[sweets alert]';
article.style.backgroundColor = '#EEFF22';
è¨äºã«ã¯ã¿ã¤ãã«ãURLãå¿
è¦ãªã®ã§ãä¸è¨ã®ããã«ããããã£ã追å ãã¦ããã¾ãã
ã¤ãã§ã«å¿
é ã§ã¯ããã¾ããããç®ç«ã¤ããã«èæ¯è²ãæå®ãã¦ããã¾ãã
ãªãã½ã¼ã¹ã³ã¼ãä¸ã«æ¥æ¬èªãåãè¾¼ãã®ã¯ã¡ãã£ã¨é¢åãªã®ã§ä»åã¯å
¨ã¦è±èªã«ãã¦ãã¾ããï¼escapeã使ãå¿
è¦ãããã¾ãã詳細ã¯HatenaRssMixiMix.jsãåç
§)
次ã«è¨äºã®æ¥ä»ã»æå»ãä¿æããDateã¤ã³ã¹ã¿ã³ã¹ãè¨å®ãã¾ãã
ãã®ããããã£ã¯ãçªçµè¡¨ã®ã©ãã«è¨äºã表示ããããï¼ãã®å¤æææã«ãªãã¾ãã
var today = new Date();
today.setHours(15);
today.setMinutes(0);
article.date = today;
insertArticle(article);
ä¸è¨ã®ããã«ãå½æ¥ã®15:00ã«è¡¨ç¤ºãããããã«ã»ãããã¾ãã
æå¾ã«ã§ãããã£ã article ã insertArticleé¢æ°ã«æ¸¡ãã¦ã³ã¼ãã®ç·¨éã¯å®äºã§ãã
åºæ¥ä¸ãã£ãã¹ã¯ãªãããFirefoxã«ãã©ãã°ã¢ã³ããããããã¦ã¤ã³ã¹ãã¼ã«ããå¾ãçªçµè¡¨ãå®éã«è¦ã¦ã¿ã¾ãããã
ãã®ããã«çªçµè¡¨ã«è¡¨ç¤ºããã¦ããã¯ãã§ãã
ä»åæ¸ããã³ã¼ãã¯ä»¥ä¸ã®éãã§ãã
è¨äºã®ãªãã¸ã§ã¯ããä½ã£ã¦ insertArticle()é¢æ°ã«æ¸¡ãã¨ããæµãã«ãªãã¾ãã(HatenaRSSOyatsuMix.user.js)
function fetchArticles() {
var article = createArticle();
article.url = 'http://d.hatena.ne.jp/keyworddiary/%a4%aa%a4%e4%a4%c4';
article.title = 'It is time for sweets.';
article.sitetitle = '[sweets alert]';
article.style.backgroundColor = '#EEFF22';
var today = new Date();
today.setHours(15);
today.setMinutes(0);
article.date = today;
insertArticle(article);
}
article ã«è¨å®å¯è½ãªããããã£ã¯ä»¥ä¸ã®éãã§ãã
éçºã®ãã³ã
ããããã¾ã表示ã§ãã¦ããªãå ´å㯠log()ã¨ããé¢æ°ãå©ç¨ãã¦ãããã°ããã¨è¯ãã§ãããã
logé¢æ°ã«æååã渡ã㨠JavaScriptã³ã³ã½ã¼ã« ã«ãã®æååã表示ããã¾ãã
ä»åã¯ç°¡åãªä¾ãªã®ã§ãåçã«è¨äºãä¸èº«ãåå¾ãããã¨ã¯ãã¾ããã§ããã
HatenaRssMixiMixã¯ããã¯ã·ã£ããåçã«æ
å ±ãåå¾ãã¦æ¥è¨ã表示ããã¨ãããã¨ããã£ã¦ããã®ã§ãHatenaRssMixiMixã® fetchArticlesé¢æ°ãèªãã°ãããããåããã¨æãã¾ãã
ã¾ãããããã®è¨äºãã¾ã¨ãã¦çªçµè¡¨ã«è¿½å ãããå ´åã¯ãarticleã®Arrayãä½ã£ã¦ insertArticlesã¨ããé¢æ°ã«æ¸¡ãã°è¯ãã§ãããã
JSONãåºåãã¦ãããµã¼ãã¹ãå©ç¨ããã®ãé¢ç½ãããããã¾ããã
ããªãã®ä½ã£ãã¹ã¯ãªããããå¯ããã ãã
ããªããä½ã£ãã¹ã¯ãªããã便å©ãªãã®ã§ããã°ããã²ã¯ã¦ãªã¾ã§ãå¯ããã ããã
詳細ã¯ããg:hatenagreasemonkey:keyword:ã¦ã¼ã¶ã¼ã¹ã¯ãªãããæ稿ãããããåç
§ãã ããã