Last active
November 11, 2022 01:25
-
-
Save FlandreDaisuki/b2617266d447aede3b63 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 EHShortcut | |
// @namespace FlandreDaisuki | |
// @include http://exhentai.org/* | |
// @include http://g.e-hentai.org/* | |
// @version 2016.03.02 | |
// @grant GM_addStyle | |
// ==/UserScript== | |
GM_addStyle(` | |
html, body { | |
height: 100%; | |
} | |
.EHSRoot { | |
margin: 0px 0px 0px 20px; | |
cursor: pointer; | |
} | |
.EHSFS{ | |
height: 100px; | |
width: 100px; | |
border: 1px solid black; | |
background-color: rgb(79, 83, 91); | |
} | |
.EHSFSB{ | |
position: fixed; | |
top: 0px; | |
left: 0px; | |
height: 100vh; | |
width: 100%; | |
background-color: rgba(0, 0, 0, 0.4); | |
display: flex; | |
z-index: 2; | |
align-items: center; | |
justify-content: center; | |
} | |
.EHSFSB.hidden { | |
visibility: hidden; | |
} | |
`); | |
function RemoveUrlPage(url) { | |
var [umatch, upath, usearch] = url.match(/https?:\/\/[^\/]*(?:([^?]*)(.*))/); | |
if (upath === '/') { | |
return RemoveUrlParameter(umatch, ['page']); | |
} else { | |
return umatch.replace(/\d+$/, ''); | |
} | |
} | |
function RemoveUrlParameter(url, rmParameters) { | |
var [umatch, upath, uparameter] = url.match(/([^\?]*)\?(.*)/); | |
var uparas = uparameter.split('&'); | |
var resParas = uparas.filter((p) => { | |
return rmParameters.every((rp) => { | |
return p.indexOf(rp + '=') !== 0; | |
}); | |
}); | |
if (resParas.length > 0) { | |
return `${upath}?${resParas.join('&')}`; | |
} else { | |
return upath; | |
} | |
} | |
function Elem(tagName, options) { | |
var elem = document.createElement(tagName); | |
for (let opt of Object.keys(options)) { | |
elem[opt] = options[opt]; | |
} | |
return elem; | |
} | |
var nb = document.querySelector('#nb'); | |
var EHSRoot = Elem('a', { | |
className: 'EHSRoot', | |
innerHTML: 'Shortcuts' | |
}); | |
nb.appendChild(EHSRoot); | |
var EHSFSB = Elem('div', { | |
className: 'EHSFSB hidden' | |
}); | |
var EHSFS = Elem('div', { | |
className: 'EHSFS' | |
}); | |
document.body.appendChild(EHSFSB); | |
EHSFSB.appendChild(EHSFS); | |
EHSFSB.addEventListener('click', function() { | |
EHSFSB.classList.add('hidden'); | |
}); | |
EHSFS.addEventListener('click', function(event) { | |
event.stopPropagation(); //remove bubbling | |
}); | |
EHSRoot.addEventListener('click', function() { | |
EHSFSB.classList.remove('hidden'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment