-
-
Save anonymous/009b0c272da1857975061ae4b8a635bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name E-Hentai - Test Banners 3.0 | |
// @include https://e-hentai.org/* | |
// @include https://forums.e-hentai.org/* | |
// ==/UserScript== | |
document.addEventListener('dblclick', function(e) { | |
if (!e.target) | |
return; | |
if (e.target.nodeName === 'IMG' && e.target.clientWidth === 770 && e.target.clientHeight === 136) { | |
if (e.target.parentNode.id == 'botm') { | |
var input = document.createElement('input'); | |
input.setAttribute('type', 'file'); | |
input.addEventListener('change', function(e) { | |
if (!e.target.files.length || !/^image/.test(e.target.files[0].type)) return; | |
var reader = new FileReader(); | |
reader.onload = function(data) { | |
document.querySelector('#botm > img').style.cssText = | |
'padding-left: 770px; box-sizing: border-box; background: url(' + data.target.result + ')'; | |
}; | |
reader.readAsDataURL(e.target.files[0]); | |
}, false); | |
document.body.appendChild(input); | |
input.style.cssText = 'display: block; width: 0; height: 0; overflow: hidden; opacity: 0'; | |
input.click(); | |
} else { | |
var canvas = document.createElement('canvas'), context = canvas.getContext('2d'); | |
canvas.setAttribute('width', 971); | |
canvas.setAttribute('height', 284); | |
canvas.className = 'bannerCanvas'; | |
var background = new Image(); | |
background.onload = function() { context.drawImage(this, 0, 0); }; | |
background.src = 'http://i.imgur.com/sHO93Lf.png'; | |
var banner = new Image(); | |
banner.onload = function() { context.drawImage(this, 97, 13); }; | |
banner.src = e.target.src; | |
e.target.parentNode.insertBefore(canvas, e.target); | |
e.target.style.display = 'none'; | |
} | |
} else if (e.target.nodeName == 'CANVAS' && /bannerCanvas/.test(e.target.className)) { | |
e.target.nextElementSibling.style.display = null; | |
e.target.parentNode.removeChild(e.target); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment