Greasemonkey ã§ è¶ ãæ軽㫠jQuery ã使ãã¹ãããã [Chrome 対å¿ç]2011-06-07
æ§çã§ãããGreasemonkey 㧠è¶
ãæ軽㫠jQuery ã使ãã¹ãããã 㯠Firefox ã§ä½¿ç¨ããåã«ã¯åé¡ãªãã®ã§ãããChrome ã§ã¯ã»ãã¥ãªãã£ä¸ã®é½åããGreasemoneky ä¸ã«ããã unsafeWindow ã unsafe ã§ã¯ç¡ããã㧠(ï¼) unsafeWindow.jQuery ãªã©ã« Greasemoneky ããã¢ã¯ã»ã¹ãããã¨ãåºæ¥ã¾ããã
ããã§ãChrome 対å¿çã®ã¹ãããããç¨æãã¾ããã
ãã ãããã° Chrome ã®ã»ãã¥ãªãã£ãåé¿ããæ¸ãæ¹ã«ãªããããæ§çã«ãã£ããã該å½ãã¼ã¸ã§ãã§ã« jQuery ãèªã¿è¾¼ã¾ãã¦ããã°ãããå©ç¨ãã¨ããç¹å¾´ã失ããã¦ãã¾ã£ã¦ãã¾ãã
éã«è¨ãã°ã常ã«èªåã§æå®ãããã¼ã¸ã§ã³ãå©ç¨ã§ããã®ã§ãjQuery ã®æ°ããæ©è½ã使ã£ãã¹ã¯ãªãããæ¸ãå ´åãªã©ã¯ããã¡ãã®ã»ããåªãã¦ãã¾ãã
ããã§ãChrome 対å¿çã®ã¹ãããããç¨æãã¾ããã
ãã ãããã° Chrome ã®ã»ãã¥ãªãã£ãåé¿ããæ¸ãæ¹ã«ãªããããæ§çã«ãã£ããã該å½ãã¼ã¸ã§ãã§ã« jQuery ãèªã¿è¾¼ã¾ãã¦ããã°ãããå©ç¨ãã¨ããç¹å¾´ã失ããã¦ãã¾ã£ã¦ãã¾ãã
éã«è¨ãã°ã常ã«èªåã§æå®ãããã¼ã¸ã§ã³ãå©ç¨ã§ããã®ã§ãjQuery ã®æ°ããæ©è½ã使ã£ãã¹ã¯ãªãããæ¸ãå ´åãªã©ã¯ããã¡ãã®ã»ããåªãã¦ãã¾ãã
ã¹ã¯ãªãã
(function (d, func) { var h = d.getElementsByTagName('head')[0]; var s1 = d.createElement("script"); s1.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"); s1.addEventListener('load', function() { var s2 = d.createElement("script"); s2.textContent = "jQuery.noConflict();(" + func.toString() + ")(jQuery);"; h.appendChild(s2); }, false); h.appendChild(s1); })(document, function($) { // ããã«ã¡ã¤ã³ã®å¦çãæ¸ã $('#button').click(function(){ alert('clicked!'); }); });
ã«ãã´ãª: Development ã¿ã°: greasemonkey jquery javascript