以ä¸ã¯ http://www.example.com/foo/bar/baz.user.js ããã¤ã³ã¹ãã¼ã«ããã¨ããåæã
@resource
// @resource resourceName1 http://www.example.com/resource1.png // @resource resourceName2 resource2.js // @resource resourceName3 /resource3.css
ã¹ã¯ãªããã¨åããã£ã¬ã¯ããªã«2ã¤ç®ã®ãã¼ã§æå®ãããªã½ã¼ã¹ãä¿åããããresourceName2
ã¯http://www.example.com/foo/bar/resource2.jsãresourceName3
ã¯http://www.example.com/resource3.cssã
resourceName
ã¯ã¦ãã¼ã¯ã§ãªããã°ãªãããJavaScriptãXML/CSSã®å½åè¦åã«æ²¿ã£ããã®ã«ãã¹ããã¾ãããããå¤ãªååã¯ä»ããªãã§ããããã¨ã©ã¼ã¨ãåºãªãã£ããã©ã
ãªã½ã¼ã¹ã®ä¿åã¯userscriptãã¤ã³ã¹ãã¼ã«ããæã®ã¿è¡ãããã®ã§å¾ããæ°ãããã¼ã追å ãããã¢ã³ã¤ã³ã¹ãã¼ã«ãã¦ããåã¤ã³ã¹ãã¼ã«ãå¿
è¦ã
2ã¤ç®ã®ãã¼ã«ä½¿ç¨ã§ããã¹ãã¼ã ã¯http(s)ã¨ftpã
GM_getResourceURLãGM_getResourceText
@resource
ã§ä¿åãããªã½ã¼ã¹ã使ããGM_getResourceURL('resourceName1')
ã§resource1.png
ãbase64ã§ã¨ã³ã³ã¼ããããã®ãGM_getResourceText('resourceName2')
ã§resource2.js
ã®ä¸èº«ã
@require
// @require foo.js // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
@resource
ã¨ã»ã¼åããéãã¯ä¸èº«ãåãåºããªãã¦ãå®ç¾©ãããé¢æ°çã使ããç¹ã2è¡ç®ã ã¨jQueryãä¿åããã¦ä½¿ããããã«ã
finalUrl
GM_xmlhttpRequest({ method:"GET", url:"http://www.greasespot.net/", headers:{ "User-Agent":"Mozilla/5.0", // Recommend using navigator.userAgent when possible "Accept":"text/xml" }, onload:function(response) { alert([ response.status, response.statusText, response.readyState, response.responseHeaders, response.responseText, response.finalUrl ].join("\n")); } });
ãªãã¤ã¬ã¯ããããå ã®URLããããã
追è¨
ãã®ã¨ã³ããªã¨åãããã«æ°æ©è½ãç´¹ä»ãã¦ããã¨ã³ããªãå¹¾ã¤ãè¦ã¤ãããã ãã©ãJSãã¡ã¤ã«ã@resourceã§ä¿åãã¦GM_getResourceTextã§åãåºãã¦evalãã¦ããä¾ãæãã¦ãã®ã¯ä½ãç¹å¥ãªçç±ããããã ãããã使ãããæã ãèªã¿è¾¼ãã¨ã?@requireã§ã§ããã©ã¤ãã©ãªãä¿åããã¹ã¯ãªããã®å®è¡æã®ãªã¼ãã¼ãããã¨ãããã®ããªããå®è£ ãèªãã§ãªãã®ã§ãªãã¨ããããªãã