Skip to content

Instantly share code, notes, and snippets.

@mirakui
Created October 10, 2010 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirakui/618846 to your computer and use it in GitHub Desktop.
Save mirakui/618846 to your computer and use it in GitHub Desktop.
dmm_util.user.js
// ==UserScript==
// @name DMM Util
// @description DMM Utility
// @match http://www.dmm.co.jp/*
// ==/UserScript==
(function() {
function replaceImg(img) {
var src = img.src
img.onload = function(){
img.width = img.naturalWidth;
img.height = img.naturalHeight;
}
if (src.match(/ps\.jpg$/)) {
img.src = src.replace(/ps\.jpg$/, "pl.jpg");
}
else if (src.match(/pt\.jpg$/)) {
img.src = src.replace(/pt\.jpg$/, "ps.jpg");
}
else if (src.match(/-\d+\.jpg$/)) {
img.src = src.replace(/-\d+\.jpg$/, "jp$&");
}
}
window.addEventListener("load", function() {
if (!unsafeWindow.$$) {
return ;
}
unsafeWindow.$A(unsafeWindow.$$("img[src^='http://pics.dmm'][src$='.jpg']")).each(function(img) {
replaceImg(img);
});
var samplevideo = unsafeWindow.$$("#sample-video").first();
if (samplevideo) {
samplevideo.insert('<iframe src="' + window.location.href + 'ajax=movie" width="680" height="490" scrolling="no" style="border:none"/>');
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment