Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.