èªå€§åŠæ³ã®äž»åŒµã䌎ãé·ãéå±ãªçŽ¹ä»
ãã€ãã®ããã«ããã®äžçã§ã¯äœããç§ã«ã¯ããŸãåããªãããšãçºèŠããã ã€ãŸãããã¹ã¯ãããã³ã³ãã¥ãŒã¿ãŒã®æ€çŽ¢ãšã³ãžã³ã«ããçš®ã®é·ãã¯ãšãªãå ¥åããŠããã¿ãã¬ããã«åãæ¿ãããšããŸã£ããåãçµæãåŸãããã«ã¯ãšãªã®ããã¹ããéèªçã«æãåºããŸããã§ããã ãã¹ãŠãé 調ã«å§ãŸããŸããã ç§ã¯æ€çŽ¢ãšã³ãžã³ã§ç§ã®è³ªåãžã®çããžã®ãªã³ã¯ãèŠãŸããããããŠãããé·ãèªæžåé¡ãçŽæããããšãå®çŸããŸããã 次ã«ãã³ã³ãã¥ãŒã¿ãŒã®é»æºãåããã¿ãã¬ããã§ãœãã¡ã«åããŸãããæ€çŽ¢ãšã³ãžã³ã«ãã¹ãŠãåå ¥åããã¿ãã¬ããã§ãã®ãªã³ã¯ãéããèœã¡çããŠãããå¿«é©ãªäœçœ®ã«æšªããã£ãŠãèªã¿ãŸã...ã ã£ãã ããã¹ãå ã®ããã€ãã®å°ããªäžäžèŽ-ç§ã®ãªã³ã¯ã¯æ€çŽ¢ãšã³ãžã³ã§ã¯ãªããªããŸããã ãªã³ã¯èªäœãåçããããšããªãã·ã§ã³ã§ã¯ãããŸãããé·ãããŸãã ã¯ãšãªããã¹ãã®ãªãã·ã§ã³ã«æžæããç§ã¯ã¿ãã¬ãããå£ãããšã«ã»ãšãã©æããŸããã ãããŒãèµ·ããŠãã³ã³ãã¥ãŒã¿ãŒã®é»æºãå ¥ãçŽããŠããã©ãŠã¶ãŒãèµ·åããå±¥æŽãæãäžããŠãèŠæ±ã®æ£ç¢ºãªããã¹ããèŠã€ããªããã°ãªããŸããã§ããã
Chromeããã³Firefoxã«ã€ã³ã¹ããŒã«ãããæ¡åŒµæ©èœ
ã¢ã€ãã¢
ç§ã¯èããŸããããéããŠããã¿ãããµãŒããŒãä»ããŠä»ã®ã³ã³ãã¥ãŒã¿ãŒã«è»¢éããããã§åŒãç¶ãäœæ¥ã§ããããã«ãããã©ãŠã¶ãŒçšã®æ¡åŒµæ©èœãäœæããã®ã¯è¯ãããšã§ãã ã¯ããäžéšã®ãã©ãŠã¶ã«ã¯ãã§ã«ã¯ã©ãŠãæ©èœããããŸããäž¡æ¹ã®ããã€ã¹ã«ãã°ã€ã³ããã ãã§... ...ãããåé¡ã§ãã ããããã³ã³ãã¥ãŒã¿ãŒã«Chromeããããã¿ãã¬ããã«Firefoxãããå Žåã¯ã©ããªããŸããïŒ ãããŠ...ããããã°ã€ã³ããã ãã§ãã ããã§ãGoogleã¢ã«ãŠã³ãã®ãã¹ã¯ãŒããæãåºããå Žåã ãŸããFirefoxã«ã¯ã¢ã«ãŠã³ãããããŸããã ã¢ã«ãŠã³ãããããã©ããããç¥ããŸãããïŒ ãã¡ãããç»é²ããŠãããããäœããã®åœ¢ã§ç®çã®ãªã³ã¯ãèªåã«æããããšãã§ãããµãŒãããŒãã£ã®ã¯ã©ãŠããµãŒãã¹ããããŸãã ãã ããããã«ç»é²ããŠå¥ã®ãã¹ã¯ãŒãããã£ãããšèšæ¶ããå¿ èŠããããŸã...ããããããã¯å®å šã«éçŸå®çã§ãã æçµçã«ãã¡ãŒã«ãä»ããŠãªã³ã¯ãèªåã§æããããšãã§ããŸãã ããããããã¯ãã¹ãŠæéãããããã¢ãã¬ã¹ããŒããã³ããŒããŠè²Œãä»ããŠãããã¢ãã¬ã¹ããŒã«è²Œãä»ããŸããããã¯ãããšãã°ã¿ãã¬ããã§ã¯éåžžã«äžäŸ¿ã§ãã ããããããã¯ãªãããã®ãã³ã»ã³ã¹ã§ã...
ãœãã¡ã«æšªããã£ãŠãç§ã¯ãã£ãããšããããã¹ãŠã®è¡åãããŸãã«ãå€ãã®åããå¿ èŠãšããããšã«æ°ã¥ããŸãã...ããããã¿ããªãããããŸããã ãããŠããã®äžçã§äœããç§ã«åããªãããšãç解ããããç§ã¯åº§ã£ãŠèªåã®ããæ¹ã§ãã¹ãŠãè¡ãã³ãŒããæžããŸãã ç§ã¯ãã¿ãã¬ãããšãã¹ã¯ãããã³ã³ãã¥ãŒã¿ãŒã®äž¡æ¹ã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ã§æ¿èªãããŠãããšæããŸããã ãŸããããšãã°åãã³ã³ãã¥ãŒã¿ãŒäžã®ç°ãªããã©ãŠã¶ãŒã§ãã äžè¬çã«ãç§ã«ãšã£ãŠã®è§£æ±ºçã¯æããã§ãã-ãœãŒã·ã£ã«ãããã¯ãŒã¯ãä»ããŠãŠãŒã¶ãŒãèªèšŒããããšã
åæ çãªäœè«
ã¡ãªã¿ã«ãèªåã§äœããæžããšãã¯ããããèªåã®ããæ¹ã§ãããŸãã é«åºŠãªããŒãããã¯ã«çŽç²ãªjavaScriptãèšè¿°ããgithubã䜿çšããããµãŒãããŒãã£ã®ã©ã€ãã©ãªã䜿çšãããjqueryã䜿çšããŸããã ãããã£ãŠããã©ãŠã¶ãŒæ¡åŒµæ©èœã®äœææ¹æ³ã«é¢ãããã¥ãŒããªã¢ã«ã¯ãããŸããã ããã¯æããŸããã ç§ã®ããã«ããªãã§ãã ããã èŠåããŸã-ããã¯æªãäŸã§ãã ç§ã¯ãŸãã圌ãã®åå¿ãäºæ³ããŠããã¹ãŠã®æœåšçãªæ¹è©å®¶ã«äŒãããã§ã-ã¯ããç§ã¯ããªãã®ãã¹ãŠã®æ£ããæãã«å®å šã«åæããŸãã ã¯ããã¹ã¯ãªããå šäœã1ã€ãŸãã¯2ã€ã®ãã¡ã€ã«ã«æŒã蟌ãããšã¯ã§ããŸãããããµã©ãã®ããã«ãã¹ãŠã现ããåãå»ãã§ãã³ãã³ãã©ã€ã³ããé·ãã¹ããŒããªã³ãã³ãã䜿çšããŠ3æéåéã§ããããã«ããå¿ èŠããããŸãã ã¯ããjavascriptã³ãŒããšhtmlã³ãŒãã1ã€ã®ãã¡ã€ã«ã«çµåããããšã¯ã§ããŸãã-ããããçµåããå¥ã®ã¬ãã«ã®æœè±¡åãå°ç¡ãã«ããããšããå§ãããŸãã ã¯ããããŒãã«ã¬ã€ã¢ãŠãã䜿çšããããšã¯ã§ããŸããããããŸããŸãããããã¯éã§ãïŒ ãããŠãããã«ãã-ä»ã圌ãã¯ç§ãçãããŸã-innerHtmlã䜿çšããŠè€éãªhtmlæ§é ãäžæã«äœæããããšã¯ã§ããŸããããã«ãŒãå ã®ãã¹ãŠã®åãã¢ã¿ããããã³ãã¿ããããåãã³ãã©ãŒãæ éã«ã¢ã¿ããããŠåé€ããå¿ èŠããããŸã...ã¯ããç§ã¯ãã¹ãŠééã£ãŠããŸãã 眪深ããæãæ¹ããã ããããç§ã¯æèçã«ãããè¡ããŸããç°¡åã ããã§ãã ãããŠèª°ãç§ãçŠããŸããïŒ æåŸã«ãããã¯éæ³ã§ã¯ãããŸãããïŒ éçºããã»ã¹å³ã¯äžå¿ èŠã«è€éã§ãããšèããŠãããããçŸä»£ã®modãå¿ èŠãšããããã«ããã°ã©ãã³ã°ããæ¹æ³ãããããŸããããŸããè©ŠããããããããŸããã ç§ã¯èªåã®æã§ã³ãŒããæžããäžè¡ãæžããã«ä»ã®äººã®äœåãããããæ§ç¯ããã®ã§ã¯ãããŸããã ãã ããç§ã®ã³ãŒãã¯è»œéã§ãããç¹å¥ãªããŒã ãçµã¿ç«ãŠãå¿ èŠã¯ãªããããã«åäœããŸãã F5ãã¯ãããžãŒã䜿çšããŠã³ãŒããæžããŠããŸãã ããã¯ãéçºããã»ã¹ã§çŸåšã®ããŒãžã§ã³ãã©ã®ããã«æ©èœãããã確èªããããã«ãF5ãã©ãŠã¶ãŒãã¯ãªãã¯ããã ãã§ãã
ãã ãããã以å€ã®å Žåã¯æ¡åŒµæ©èœããã¹ãã«åæ Œããªãããããã³ãã©ãŒãã«ãŒãã§åæããå¿ èŠããããŸããã ãŸãã念ã®ããæ¡åŒµæ©èœã§ã¯ãhtmlã€ã³ããã¯ã¹ãã¡ã€ã«ã§-çªç¶-åçã«æ¥ç¶ãããã¹ã¯ãªããã¯çŠæ¢ãããŠããŸãã ããã§ãã¹ã¯ãªããã¿ã°ãä»ããŠããããæ¥ç¶ããŸããã
ã¿ãã¹ãã¬ãŒãž
ããã§ããã©ãŠã¶ã§éããã¿ããç¹å®ã®ãªã¹ãã«ä¿åããããšã決å®ããŸããããã®ãªã¹ãã¯ãã³ã³ãã¥ãŒã¿ãŒ-ããŒã ã³ã³ãã¥ãŒã¿ãŒãè·å Žã³ã³ãã¥ãŒã¿ãŒãããŒã«ã«ã³ã³ãã¥ãŒã¿ãŒãšåŒã°ããŸãã ããŒã«ã«ãšã¯ããªã¹ãããµãŒããŒäžã§ã¯ãªããã©ãŠã¶ãŒããŒã¿ããŒã¹ã«ä¿åãããŠããå Žåã§ããããããã£ãŠããªã¹ãã®ä¿åå ã®ãã©ãŠã¶ãŒã§ã®ã¿äœ¿çšã§ããŸãã ããã¯ãç°ãªãã³ã³ãã¥ãŒã¿ãŒéã§ã¹ããŒããå¿ èŠã®ãªãã¿ãçšã§ãã ãŸããæ®ãã®ãªã¹ãã¯ãæ¡åŒµæ©èœã§ãµããŒããããŠãããã®ã®äžããä»»æã®ã³ã³ãã¥ãŒã¿ãŒãšãã©ãŠã¶ãŒã§è¡šç€ºã§ããŸãã
åã¿ãã«ã€ããŠããŠãŒã¶ãŒã¯ä»»æã®ããã¹ãã³ã¡ã³ããæ®ãããšãã§ããŸãã ããšãã°ãã·ãªãŒãºãèŠãŠãããšãã«åæ¢ããã·ãªãŒãºãèŠããŠãããšäŸ¿å©ã§ãããŸããã¿ã€ãã«ããªã³ã¯ã®çš®é¡ãæ確ã§ãªãå Žåã¯ãããŒãžã®å 容ãèªåã§ããŒã¯ããŠãããšäŸ¿å©ã§ãã
ChromeãšFirefoxã®æ¡åŒµæ©èœã®äœæã«é¢ããããã¥ã¡ã³ãã«ãããšãæ¡åŒµæ©èœã³ãŒãã¯ã¡ã€ã³ãšããã¯ã°ã©ãŠã³ãã®2ã€ã®ãã¡ã€ã«ã«é 眮ããå¿ èŠããããŸãã ã¡ã€ã³ã¹ã¯ãªããã¯ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®è¡šç€ºãåŠçããããã¯ã°ã©ãŠã³ãã¹ã¯ãªããã¯ãã©ãŠã¶ãŒã®ã¿ããå¶åŸ¡ãããµãŒããŒãšããŒã¿ã亀æã§ããŸãã ChromeãšFirefoxã®ã¿ãã®ç®¡çã¯éåžžã«äŒŒãŠããŸãã ããšãã°ãChromeã§ã¿ããéãããéãããããããã®ã€ãã³ããã³ãã©ãŒã¯æ¬¡ã®ããã«ãªããŸãã
chrome.tabs.onUpdated.addListener( function(tabId, changeInfo) { });
ãããŠãFirefoxã§ã¯æ¬¡ã®ããã«ãªããŸãã
browser.tabs.onUpdated.addListener( function(tabId, changeInfo, tabInfo) { });
ãããŠãéããŠãããã¹ãŠã®ã¿ãã®ãªã¹ãã衚瀺ããé¢æ°ã¯ãäž¡æ¹ã®ãã©ãŠã¶ãŒã§åãããã«èšè¿°ãããŠããŸãã
chrome.tabs.query({},function(data){ });
ã¯ããã¯ããã¯ãã ã¯Firefoxã§ãæžãããŠããŸã...ãªã© ããã¯å°ãå¥åŠã§ããããã©ãŠã¶ãAPIã®æšæºåã«åãã£ãŠãããšããäºå®ã¯éåžžã«åæ°ã¥ããããŸãã
å®éã«ã¯ãæ¡åŒµæ©èœã®ãã¹ãŠã®æ©èœã¯ãããã€ãã®æ©èœã䜿çšããŠå®çŸãããŸã-ã¢ã€ã³ã³ãã¯ãªãã¯ããŠæ¡åŒµãŠã£ã³ããŠãéããéããŠããã¿ããèªã¿åããã¿ããéããæ°ããã¿ããäœæããã¿ãã€ãã³ãããªãã¹ã³ããæ¡åŒµãŠã£ã³ããŠãšããŒã¿ã亀æããŸãã ããã ãã§ã ãããã®ã¡ãœããã¯ãããã¯ã°ã©ãŠã³ãã¹ã¯ãªããããã®ã¿äœ¿çšã§ããŸãã
èªã¿åãåŸããã©ãŠã¶ãŒã§éãããã¿ãã¯ãµãŒããŒã«éä¿¡ãããéåžžã®SQLããŒã¿ããŒã¹ã«ä¿åãããŸãã ãµãŒããŒã¹ã¯ãªããã¯PHPã§èšè¿°ãããŠããŸãã ããŒã¿ããŒãã«ãšããå¥ã®ããŒãã«ã®è¡ãžã®ãªã³ã¯ãæ ŒçŽãããŠãŒã¶ãŒããŒãã«ããããŸãã ãã®ããŒã¿ã¯ãããŒãžã®ã¢ãã¬ã¹ãããŒãžã®ååããŠãŒã¶ãŒã®ããã¹ãã³ã¡ã³ãã§ãããçŽ1ãããã€ãé·ã®ããã¹ãã¿ã€ããã£ãŒã«ãã«ããã¹ãæååã®åœ¢åŒã§ä¿åãããŸãã ããŒã¿ã¯æå·åãããŠããªã圢åŒã§ä¿åãããŸãã 1ã¡ã¬ãã€ããããçŽ1,000åã®ã¿ããä¿åã§ããŸãã ãŠãŒã¶ãŒããšã«æ倧25åã®ã¹ãã¬ãŒãžïŒãã³ã³ãã¥ãŒã¿ãŒãïŒãæäŸãããŸãã
ãã ããæ¡åŒµæ©èœã®ç¡æããŒãžã§ã³ã§ã¯ããŠãŒã¶ãŒã¯2ã€ã®ã¹ãã¬ãŒãžïŒããŒã ã³ã³ãã¥ãŒã¿ãŒãšä»äºçšã³ã³ãã¥ãŒã¿ãŒïŒã«å¶éãããåã¹ãã¬ãŒãžã¯10åãŸã§ã®ã¿ããä¿åã§ããŸãã ç§ã¯ãŸã ææçãšæ¯æãæ¹æ³ã«åãçµãã§ããŸãã æ倧25å°ã®ãã³ã³ãã¥ãŒã¿ãŒããšããããçŽ1000åã®ã¿ãããããèæ¯ç»åãåã³ã³ãã¥ãŒã¿ãŒã®ã¢ã€ã³ã³ãšååãéå±€ãªã¹ããªã©ãéžæã§ããŸãã
å¥ã®ãªããžããª-ããŒã«ã«ã³ã³ãã¥ãŒã¿ããããŸãã ã¿ãããŒã¿ã¯ãŠãŒã¶ãŒã®ã³ã³ãã¥ãŒã¿ãŒã®ããŒã«ã«ãã©ãŠã¶ãŒããŒã¿ããŒã¹ã«ä¿åããããããããã§ã¯å¶éã¯ãããŸããã ããã«ã¯ã奜ããªã ãã¿ããä¿åã§ããŸãããããŒããã©ã€ããèš±å¯ãã以äžã®ã¿ãã¯ä¿åã§ããŸããã ããã«ãããŒã¿ã¯ããŒã«ã«ã¹ãã¬ãŒãžã§ã¯ãªãindexedDBã«æ ŒçŽãããããã5ãŸãã¯æ°ã¡ã¬ãã€ãã®å¶éã¯ãããŸããã éèŠãªããšã¯ããã©ãŠã¶ã®å±¥æŽãšãšãã«ãã®ãªããžããªã誀ã£ãŠæ¶å»ããªãããšã§ãã ãŸããã¿ããããã¹ããã¡ã€ã«ã«ãšã¯ã¹ããŒãããã³ã€ã³ããŒãããäºå®ã§ãã
indexedDBã䜿çšããããã«ãé·ãã106è¡ãããªãå°ããªãµãã©ã€ãã©ãªãäœæããŸããã ãµãŒããŒäžã®ããŒã¿ããŒã¹ãšã¯ç°ãªããããã§ã¯ãã¹ãŠã®ããŒã¿ãããã¹ãæååã«æœåºããå¿ èŠã¯ãããŸããããé£æ³é åã«ãã®ãŸãŸä¿åã§ããŸãã ããã«ããã¹ãã¬ãŒãžã®åçã¯ããã§ãïŒããŒã¯äŸ¡å€ã§ãã ãŸããå€ã¯å·šå€§ãªé£æ³é åã«ãªãå ŽåããããŸãã
ãŠãŒã¶ãŒèªèšŒ
Firefox
æ¢ã«è¿°ã¹ãããã«ãæ¿èªã¯ãœãŒã·ã£ã«ãããã¯ãŒã¯ãä»ããŠè¡ããããµãŒããŒã§ã¯OAuthãããã³ã«ã䜿çšããŸãã FacebookãšVKontakteã§åŒãç¶ããµããŒããããŠããŸããããŠãŒã¶ãŒãèªèšŒããæ¹æ³ã®æ°ãå¢ããäºå®ã§ãã OAuthãµãŒããŒèªèšŒã¹ããŒã ã¯ãäž¡æ¹ã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ã®ããã¥ã¡ã³ãã§è©³çŽ°ã«èª¬æãããŠããããã詳现ã«èª¬æããæå³ã¯ãããŸããã ãŠãŒã¶ãŒãæ¢ã«ãœãŒã·ã£ã«ãããã¯ãŒã¯ã«ãã°ã€ã³ããŠãããæ¢ã«æ¡åŒµæš©éãä»äžããŠããå Žåã§ããæ¿èªäžã«æ°ãããã©ãŠã¶ãŒã¿ããéããšããäºå®ãæ°ã«å ¥ããªãã£ãããšã«ã®ã¿æ³šæããŠãã ããã ãã®ã¿ãã¯ãããã¯ã°ã©ãŠã³ãæ¡åŒµã¹ã¯ãªããã«ãã£ãŠãã£ããããããã®åŸåŒ·å¶çã«éããããŸããäžè¬ã«ãèŠãç®ã¯çŸãããªããä»ã®ã¿ãã«æŒã蟌ãŸããŠã衚瀺ãããŠç Žæ£ããããšç¹æ» ããŸãã
ãããéããã«ã¯ãVKontakteã®å Žåãã¿ãã€ãã³ããã³ãã©ãŒã§ã¢ãã¬ã¹ã®ååšã確èªããå¿ èŠããããŸãã
oauth.vk.com/blank.html
Facebookã®å ŽåïŒ
https://www.facebook.com/connect/blank.html
念ã®ããïŒ
facebook.com/connect/login_success.html
ãã®ãããæåã«æ¡åŒµã¢ã»ã³ããªãGoogle Web Storeã«éä¿¡ãã察å¿ããã¯ã©ã€ã¢ã³ãjavascript apiãœãŒã·ã£ã«ãããã¯ãŒã¯ã®äºåãã«ã¢ããã䜿çšããŠãã¯ã©ã€ã¢ã³ãã§èªèšŒãå®è¡ããŸããã ããã«ãæ¡åŒµæ©èœã¯ãŠãŒã¶ãŒã«ã€ã³ã¹ããŒã«ãããŠããããµãŒããŒã§èªèšŒããå¿ èŠããããããiãã¬ãŒã ã®æ¡åŒµæ©èœã®ããã¯ã°ã©ãŠã³ãã¹ã¯ãªããã§ããµãŒããŒããhtmlããã«ã¢ããããŸããããæ¢ã«ãœãŒã·ã£ã«ãããã¯ãŒã¯APIããã«ã¢ããããŠããŸã...
ãããŠããµãŒããŒãšã®ããŒã¿äº€æã¹ããŒã ã¯ãã®ãããªãã®ã§ããã æ¡åŒµã€ã³ããã¯ã¹ããŒãžã¯ãã³ãã³ãïŒã¯ãªãã¯æ å ±ãªã©ïŒãããã¯ã°ã©ãŠã³ãæ¡åŒµã¹ã¯ãªããã«éä¿¡ããŸãã postMessageã䜿çšããããã¯ã°ã©ãŠã³ãã¹ã¯ãªããã¯ãiãã¬ãŒã htmlã«ããŒã¿ãéä¿¡ããŸãã Iãã¬ãŒã ã¯ããµãŒããŒäžã®phpã¹ã¯ãªããã«ããŒã¿ãéä¿¡ããŸãã ãµãŒããŒã¯iãã¬ãŒã ã§å¿çããiãã¬ãŒã ã¯ããã¯ã°ã©ãŠã³ãã¹ã¯ãªããã§å¿çããããã¯ã°ã©ãŠã³ãã¹ã¯ãªããã¯ã€ã³ããã¯ã¹ã§å¿çãããŠãŒã¶ãŒã«ã¯çãã衚瀺ãããŸãã ããŒã...ãããŠãæãéèŠãªããš-ããã¯ãã¹ãŠããŸããããŸããïŒ
äžè¬ã«ãããã¯æ©èœããŸããã§ããã Googleã¯æ¡åŒµæ©èœãããã€ãã®æèšã§å²ã¿ãŸãããããã®äžã«ã¯ãæ¡åŒµæ©èœãã»ãã¥ãªãã£ããªã·ãŒã«æºæ ããŠããªããšããæŒ ç¶ãšããèšèããããŸããã ãµããŒããšã®ããåããéããŠã詳现ãéæããããšãã§ããŸããã ã€ãŸããæ¡åŒµæ©èœããµãŒãããŒãã£ã®ãµãŒããŒããhtmlãšjsããã«ã¢ãããããšããäºå®ã奜ãã§ã¯ãããŸããã§ãã...äžè¬ã«ãç§ã¯ã¯ã©ã€ã¢ã³ãã®æ¿èªãåŸãŠããµãŒããŒã®æ¿èªãåŸãå¿ èŠããããŸããã ã¯ããããã¯ã°ã©ãŠã³ãæ¡åŒµã¹ã¯ãªããããhttp postãªã¯ãšã¹ãããµãŒããŒã«çŽæ¥éä¿¡ããŸããããèš±å¯ãããŠããããšãå€æããŸããã ããã§ããã ããã¯ããã«è¯ãã§ãã çãããšãå€æããããããœãŒã·ã£ã«ãããã¯ãŒã¯ããJavaScript APIãååŸããå¿ èŠã¯ãããŸãããããã¯ãŠãŒã¶ãŒã«ãšã£ãŠäœåãªåŸ ã¡æéã§ãã
ã¿ãã衚瀺
æ¡åŒµãªãã·ã§ã³ã«æ»ããŸãã ã¿ãã®ãªã¹ãèªäœã¯äžé£ã®è¡ã§ãããæåã«ç»åã®ãã¡ãã³ã³ã次ã«ããŒãžã¿ã€ãã«ãæåŸã«ãªã³ã¯ãç¶ããŸãã ç»é¢äžã®æå®ãããè¡ãµã€ãºã«åãŸããªããã®ã¯ããªãã³ã°ãããŸãã ãã ããããŒã¿ããŒã¹ã¯å®å šã«ä¿åãããŸãã ãŸããä»»æã®è¡ãè²ä»ãã®ã¿ã€ã«ã®åœ¢ã§ç»é¢ããåãåºãããšãã§ããŸãã ããã¯ãããããç®ã®åã«ããã¹ãæãéèŠãªãµã€ãã®ããã®ãã®ã§ãã
Chromeã¿ããªã¹ã
ã¿ã€ã«ã®è²ã¯ããµã€ãã®ãã¡ã€ã³åã«åºã¥ããŠèªåçã«éžæãããŸãã ãã®é¢æ°ã¯URLãåãå ¥ããŸãã ãã¡ã€ã³åã¯3ã€ã®ã»ãŒçããæåã°ã«ãŒãã«åå²ãããåã°ã«ãŒãã®æåã®æåã¯è²æåã®å€RãGãBã«å€æãããŸãããã®å€æã¯æ¬¡ã®ããã«å®è¡ãããŸãã ãããã®3æåã®ã³ãŒãã¯ã26ã«ããé€ç®ã®æ®ããååŸããããšã«ããã0ã25ã®ç¯å²d1ã«çž®å°ãããŸãããã·ã¢èªã®ã¢ã«ãã¡ãããã®æåããã®ç¯å²ã«çž®å°ãããŸãã 27çªç®ã®æåãæåã«æ¥ãããšã¯åé¡ã§ã¯ãããŸãããã¢ã«ãã¡ãããã®ãã¹ãŠã®æåã®è²æåãå¿ ãããç°ãªãå¿ èŠã¯ãªãã®ã§ãç¹°ãè¿ããŠã¿ãŸãããã 次ã«ãç¯å²d1ïŒ0 ... 25ïŒããåŸããã3ã€ã®æ°å€ã¯ãç¯å²d2ïŒ150 ... 255ïŒã«æ¯äŸããŠæžå°ããŸãã äžè¬ã«ããããã®ç¯å²ã¯é¢æ°ã®éå§æã«èšå®ãããä»ã®ç¯å²ã«å€æŽã§ããŸãã è²æåãæãããªãããã«150ã255ãåããŸããã ããšãã°ã0 ... 100ã«èšå®ãããšãã¿ã€ã«ã¯æããªããŸãã ãããã£ãŠããã¡ã€ã³åã®3æåã¯ã150ã255ã®ç¯å²ã®3ã€ã®æ°åã«å€æãããŸãã ãããŠããæ³åã®ãšããããããã¯ã¿ã€ã«RãGãBã®è²æåãšããŠè§£éãããŸãããã¹ãŠãéåžžã«åçŽã§ãã
getSiteColor=function(url) { var d1=[0,25], d2=[150,255]; var code=0, codep=0, color=0, str='', domen='', ar=[], inc=0; ar=url.split('//'); if (ar.length>1) {str=ar[1];} else {str=ar[0];}; str=str.split('www.').join(''); domen=str.split('/')[0]; str=domen.split('.').join(''); ar=[]; inc=Math.floor(str.length/3); if (str.length % 3 >0) {inc++;}; for (var i=0; i<str.length; i+=inc) { code=str.slice(i, i+1).charCodeAt(0); codep=code % (d1[1]-d1[0]+1); color=Math.round( codep * (d2[1]-d2[0]) / (d1[1]-d1[0]) ) + d2[0]; ar.push(color); }; return {r:ar[0], g:ar[1], b:ar[2], domen:domen}; }
HTMLããã¥ã¡ã³ãæ§é
htmlããã¥ã¡ã³ãã¯ããªãŒããŒã¬ã€ã«ãã£ãŠçµåããã絶察é 眮ãåããè€æ°ã®ãã£ã³ãã¹èŠçŽ ãšããªã¹ãã衚瀺ãããdivãããã¯ã§æ§æãããŸãã ãµã€ãºãå€æŽãããšããã©ãŠã¶ãŠã£ã³ããŠã«ãããã®ãã¹ãŠã®èŠçŽ ã®ãµã€ãºãå€æŽããé¢æ°ããã³ã°ããæ°ããé«ããšå¹ ã«èª¿æŽãããŸãã æå°ãµã€ãºãããããããå æãããŠã¹ã¯ããŒã«ããŒã衚瀺ãããŸãã èæ¯ç»åã¯äžã®ãã£ã³ãã¹ã«è¡šç€ºãããŸãã ãŠãŒã¶ãŒãããã²ãŒãããããããã«ãããŸããŸãªãªã¹ãïŒã€ãŸããã³ã³ãã¥ãŒã¿ãŒïŒã«å¯ŸããŠãããŸããŸãªèæ¯ãèšå®ããå¿ èŠããããšå€æããŸããã èæ¯ç»åã¯ããŠã£ã³ããŠã®çžŠæšªæ¯ãç¶æãããŸãŸå¡ãã€ã¶ããã泚æãåŒããªãããã«ãããã«æãããªããŸãããã®äžã«çœãåéæã®é·æ¹åœ¢ãæç»ãããŸãã ããã¯ã°ã©ãŠã³ããã£ã³ãã¹ã®äžã«ã¯ãã¡ã€ã³ã¡ãã¥ãŒã®ãã£ã³ãã¹ããããç»é¢ã®äžéšã®ã¿ãå¡ãã€ã¶ããŸãã ããŠãããã«é«ãã®ã¯divãããã¯ã§ãã¿ãã®ãªã¹ãèªäœã圢æãããŸãã ãã£ã³ãã¹ã¡ãã¥ãŒããã²ãŒã·ã§ã³ã¯ãããã©ã€ãã©ãªãä»ããŠè¡ãããŸãã
Operaããã³Yandexãã©ãŠã¶ãŒ
ããŒã«ãªãŒãŒã·ã§ã³
ã¡ã€ã³ç»é¢ã«ã¯ãã©ã°ããããã¯ãªãã¯ãããšãã€ã³ã¿ãŒãã§ãŒã¹ããã·ã¢èªãšè±èªã®éã§åãæ¿ãããŸãã ããã§ã¯ãããŒãžã¯åãã¢ãã¬ã¹ã«ãªãã€ã¬ã¯ããããŸãããã³ãã³ãã©ã€ã³ã«ãã©ã¡ãŒã¿ãŒããããŸãã ãã®ãã©ã¡ãŒã¿ãŒã¯ãä»ã®ãã¹ãŠã®èŠçŽ ãããŒãããåã«èªã¿åãããŸãã ãããŠããã®å€ã«åºã¥ããŠããããŸãã¯ãã·ã¢èªãŸãã¯è±èªã®ãã¬ãŒãºãå«ãjsãã¡ã€ã«ã¯ããã¬ãŒãºã®é£æ³é ålng_en.jsãŸãã¯lng_ru.jsã«ããŒããããŸãã ãŸããã¢ããªã±ãŒã·ã§ã³èªäœã§ã¯ãã€ã³ã¿ãŒãã§ã€ã¹ãã¬ãŒãºãå°åºããããã«ããã®é£æ³é åããã®ããã¹ãæååãžã®ãªã³ã¯ãæ¢ã«äœ¿çšãããŠããŸãã ãŸããã¢ãã¬ã¹ããŒã®å€ã«å¿ããŠãã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã®èŠçŽ ïŒbuttons_en.pngãŸãã¯buttons_ru.pngïŒãå«ããã¡ã€ã«ãããŒããããŸãã ç¹ã«å€ãã¯ãªãããã®ã¹ãã©ã€ããªã¹ãå šäœã®ééã50ãããªãããã空ã®ãã¿ã³ã1ã€äœæããŠã¢ã€ã³ã³ãšç¢æããªãŒããŒã¬ã€ããããããã°ã©ãã£ãã¯ãšãã£ã¿ã§åèšèªã®ã¢ã€ã³ã³ãšç¢æãšäžç·ã«ãã¿ã³ãäœæããæ¹ããããšå€æããŸããKb åŒãç¶ããã¶ã€ã³ã«åãçµã¿ããã¹ãŠã®ãã¿ã³ã®åœ¢ãå€ããäºå®ã§ãã
ãšã«ãããç¹å®ã®ããŒã«ã©ã€ãºã«é¢é£ä»ããããŠããªãã°ã©ãã£ãã¯èŠçŽ ãå«ãã¹ãã©ã€ãmain.pngãå«ãäžè¬ãã¡ã€ã«ãããŒããããŸãã
ãŠã§ãç
èªå® ãè·å Žã®ã³ã³ãã¥ãŒã¿ãŒããæ éã«ä¿åããããªã³ã¯ãé»è©±ããéäžã§èŠãããšãã§ããã°ãããšæããŸããã ãã ãããã¹ãŠã®ã¢ãã€ã«OSãã©ãŠã¶ãŒãæ¡åŒµæ©èœããµããŒãããŠããããã§ã¯ãããŸããã ããã§ãWebã¢ã»ã³ããªãäœæããŸããã ç¹å®ã®ã¢ãã¬ã¹ã§ãµã€ãã«ã¢ã¯ã»ã¹ãããšããœãŒã·ã£ã«ãããã¯ãŒã¯ã®1ã€ã䜿çšããŠãã°ã€ã³ããã¿ãã衚瀺ã§ããŸãã
ã¯ãããªã¹ãã«ã¿ããè¿œå ãããç·šéãããããæ¹æ³ã¯ãããŸããã ãã ããå°ãªããšããªã¹ãããã¿ããéããŠããŒãžãé²èŠ§ããããšã¯ã§ããŸãã ãã®ãµã€ãã®ã¢ãã€ã«çã§äœæ¥ãããã®äžã«ã¿ãã®ãã倧ããªãªã¹ãã衚瀺ããããšã¯äŸ¡å€ããããšæããŸãã
IE 11ã®WebããŒãžã§ã³
åºå
ç§ã¯ãããŸã§èªåã®æ¡åŒµãä¿é²ããããšã«æ¬åœã«åãçµãã§ããŸããã§ããã 圌ã¯ãœãŒã·ã£ã«ãããã¯ãŒã¯ã§ã°ã«ãŒããäœæããããã«ããåäººå šå¡ãæåŸ ããŸããã ã¯ãã圌ã¯Yandex Directã§1,500ã«ãŒãã«ã®åºåãã£ã³ããŒã³ãéå§ããŸããã 圌女ã¯ç¹å¥ãªçµæãåºããªãã£ãããå€åç§ã¯æ£ããçºè¡šãããªãã£ãã ãŸãã¯ãåé¡ã¯ãæ¡åŒµæ©èœã®ããŒã ããŒãžã®è±èªçãžã®ãªã³ã¯ã瀺ããããšã§ãã ãŸããããŒã ããŒãžã§ã¯ãªããããã«æ¡åŒµã¹ãã¢ã®1ã€ã«ãªã³ã¯ã匵ã䟡å€ããããããããŸããã ãåç¥ã®ããã«ãç§ã¯ããŒã±ãã£ã³ã°ã®å€©æã§ã¯ãããŸããã äžè¬ã«ãä»ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠåè©Šè¡ããŸãã ãã£ã³ããŒã³ã§ã¯39åã®ã¯ãªãã¯ãçºçããŸããã ãã®çµæãæ°ãããŠãŒã¶ãŒãç²åŸãããã©ãããå€æããã®ã¯å°é£ã§ãã
Firefoxã®äžã®ããŒãžã§ã³ã«ã¯å¥åŠãªç¹ã1ã€ãããŸããã
10æ17æ¥ã®çµ±èšã§ã¯ã227åã®ããŠã³ããŒãã瀺ãããŠããŸãã Yandex.Directã®ãã£ã³ããŒã³ãããã«è²¢ç®ãããã©ããã¯ããããŸããããäœããã®çç±ã§ãäœããã®çç±ã§1æ¥1ã2åããŠã³ããŒããç¶ããããŸãã åæã«ãFirefoxã®æ¡åŒµæ©èœã«ã¯ãæ¯æ¥ã®ãŠãŒã¶ãŒãšããæŠå¿µããããŸãã
ããŠã³ããŒãæ°ã227ã ã£ãã®ã«1æ¥1ã2人ã®ãŠãŒã¶ãŒããããªãã£ãçç±ã¯æããã§ã¯ãããŸããã ããããããã¯äœããã®å€±æã§ããã äžè¬çã«ãç§ã¯ãããäœã§ããããããã®äººã ãã©ãã«ããã®ãç解ããŠããŸããã§ãã...
ChromeãŠã§ãã¹ãã¢æ¡åŒµã¹ãã¢ã®çµ±èšã¯ãæ°žé ã«ããŒããããªãã¹ã±ãžã¥ãŒã«ïŒããã¯ç§ã«ã¯èŠãããŸããã§ããïŒãšæ¯æ¥5ã10人ã®ãŠãŒã¶ãŒãæºè¶³ãããŸããã
ãŸããã¢ã»ã³ããªãOperaæ¡åŒµã¹ãã¢ã«éä¿¡ããŸããã ãããã2ã€ã®ããŒãžã§ã³ãé 眮ãããããã®ããããã®ã¢ãã¬ãŒã·ã§ã³ãåŸ ããã«ãããæç¹ã§ãããã«æ°ããããŒãžã§ã³ãåºããããšããŸããã å®éãOperaãChromeã¹ãã¢ããæ¡åŒµæ©èœãå®å šã«ã€ã³ã¹ããŒã«ããå Žåããªããããå¿ èŠãªã®ã§ããã
ãŸãšã
ChromeãFirefoxãWebããŒãžã§ã³ã®3ã€ã®æ¡åŒµãã«ããäœæããŸããã å®éã3ã€ã®ã¢ã»ã³ããªã¯ãã¹ãŠåãã¢ã»ã³ããªã§ãããçŸåšäœ¿çšãããŠãããã©ãŠã¶ãšã³ãžã³ãæ§æå ã§åã«ç€ºããŠããŸãã ãããŠãã¿ããæäœããããã®å¯Ÿå¿ããé¢æ°ãåæåãããŸãã ãã®å€ãå€æŽããŠãããzipã«ããã¯ããŠããã±ãŒãžãé©åãªæ¡åŒµã¹ãã¢ã«éä¿¡ããŸãã
ChromeãšFirefoxã®ããŒãžã§ã³ã¯ãã¹ããããããããã®å ¬åŒæ¡åŒµã¹ãã¢ã«é 眮ãããŠããŸãã ããã«ãGoogleã§ã®æ¡åŒµæ©èœéçºè ãšããŠã®ç»é²ã«ã¯5ãã«ããããŸãã Mozillaã¯ç¡æã§æäŸããŠããŸãã WebããŒãžã§ã³ã®æ¡åŒµæ©èœã¯ãµãŒããŒã«ãããŸãã Chromeã¹ãã¢ã®ã¢ã»ã³ããªã¯ãäºææ§ã®ãããã©ãŠã¶ãŒã§æ£åžžã«æ©èœããŸããYandexãã©ãŠã¶ãŒãšOperaã«ãã€ã³ã¹ããŒã«ã§ããŸãã ããã«é«åºŠãªæ©èœãåããæ°ããããŒãžã§ã³ããªãªãŒã¹ããäºå®ã§ãã
äžè¬çã«ããã©ãŠã¶ã®æ¡åŒµæ©èœã¯åŒ·åã§ãã ä»ãç§ã¯ãœãã¡ããç«ã¡äžããå¿ èŠã¯ãããŸããããã¿ãã¬ãããå£ãæããå¿ èŠãããŸããã ããã¯å®å šãªçŠ ã§ãã ãã¹ãŠã«è¯ãã