2010”N05ŒŽ06“ú

“ø— ‚ÌmayŽI‚ÅURL‚ðŽw’肵‚ĉ摜ƒŒƒX‚·‚éGreasemonkeyƒXƒNƒŠƒvƒg

u“ø— ‚ÌmayŽI‚ÅURL‚ðŽw’肵‚ĉ摜ƒŒƒX‚·‚éuserContent.jsƒXƒNƒŠƒvƒgv‚ðGreasemonkey‚Å‚à“®‚©‚·‚�}‚Æ‚ª‚Å‚«‚Ü‚µ‚½B

data URI scheme‚¾‚ƃNƒƒXƒhƒƒCƒ“‚Ì–â‘è‚Í‚È‚©‚Á‚½‚̂ŁA‰æ‘œ‚ð‚ ‚ç‚©‚��‚ßbase64‚É‚µ‚�N‚¯‚ÎGreasemonkey‚Å‚à“®‚­‚¾‚낤‚ÆŽv‚Á‚Ä

img.src = input.value.substr(0, 5) === "data:" ? input.value : input.value + "?" + (new Date()).getTime();

‚Ì•”•ª‚ð

if (input.value.substr(0, 5) === "data:") {
  img.src = input.value;
} else if (typeof GM_xmlhttpRequest === "function") {
  GM_xmlhttpRequest({
    method: "GET",
    url: input.value,
    overrideMimeType: "text/plain",
    onload: function(response) { img.src = "data:image/png;base64," + btoa(response.responseText); }
  });
} else {
  img.src = input.value + "?" + (new Date()).getTime();
}

‚Æ‚µ‚½‚獡“x‚Íbtoa()‚Å"String contains an invalid character"‚Ƃ��‚¤ƒGƒ‰[‚ªo‚Ü‚µ‚½B

iFirefox‚́jbtoa()‚ÍŒˆ‚Ü‚Á‚½•ï¿½ï¿½Žš‚µ‚©•ÏŠ·‚Å‚«‚Ȃ��‚炵‚��‚Å‚·BJavascript‚ʼn摜ƒtƒ@ƒCƒ‹‚àbase64‚É•ÏŠ·‚·‚é‚É‚Í

‚Ȃǂ̃XƒNƒŠƒvƒg‚ª‚ ‚é‚»‚¤‚Å‚·‚ªAGreasemonkey‚Å‚ÌŽg‚��•û‚ª‚í‚©‚è‚Ü‚¹‚ñ‚Å‚µ‚½B“¯‚��‚悤‚ÉJavascript‚ʼn摜ƒtƒ@ƒCƒ‹‚àbase64‚É•ÏŠ·‚µ‚��‚é

‚Ì•ÏŠ·•”•ª‚ð‚»‚Ì‚Ü‚Ü^Ž—‚µ‚Ä

if (input.value.substr(0, 5) === "data:") {
  img.src = input.value;
} else if (typeof GM_xmlhttpRequest === "function") {
  GM_xmlhttpRequest({
    method: "GET",
    url: input.value,
    overrideMimeType: "text/plain; charset=x-user-defined",
    onload: function(response) { img.src = "data:image/png;base64," + btoa(response.responseText.replace(/[\u0100-\uffff]/g, function(c) { return String.fromCharCode(c.charCodeAt(0)&0xff); })); }
  });
} else {
  img.src = input.value + "?" + (new Date()).getTime();
}

‚Æ‚µ‚½‚ç“®‚«‚Ü‚µ‚½B

btoa()‚ł͑Ήž‚µ‚��‚Ȃ��•ï¿½ï¿½Žš‚ð’u‚«Š·‚¦‚é‚Ù‚©‚ɁAoverrideMimeType‚Å"text/plain"‚��‚á‚È‚­"text/plain; charset=x-user-defined"‚ÆŽw’肵‚Ȃ��‚Ƃ��‚¯‚Ȃ��‚悤‚Å‚·B

  • Windows XP SP3AFirefox 3.6AGreasemonkey 0.8.20100408.6A‚ÅŠm”F‚µ‚Ü‚µ‚½B
  • Windows XP SP3AFirefox 3.6AuserChromeJS 1.1AƒTƒuƒXƒNƒŠƒvƒgƒ[ƒ_‚È‚µAuserContent.js 1.3 mod6AuserContent.pl.js‚È‚µAGM_modoki.jsl‚È‚µA‚ÅŠm”F‚µ‚Ü‚µ‚½B
“Y•tƒtƒ@ƒCƒ‹
userContent_2chan_resUploadFromURL{may.2chan.net+b+res+^}.user.js
posted by Š|‚¯o` at 21:26 | Comment(0) | TrackBack(0) | “ú‹L | ‚}‚̃uƒƒO‚Ì“ÇŽÒ‚É‚È‚é | XVî•ñ‚ðƒ`ƒFƒbƒN‚·‚é