Last active
February 28, 2020 13:40
-
-
Save hadongsoo/e9048061d5235f1addf1b9f3a35ff4e6 to your computer and use it in GitHub Desktop.
manamoa fullscreen shortcut
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 manamoa-full-screen | |
// @version 1.0 | |
// @description F key for fullscreen | |
// @author dongsoo | |
// @include /^https?://manamoa[0-9]{0,2}\.net\/bbs\/board\.php\?bo_table=manga\&wr_id/ | |
// @grant none | |
// ==/UserScript== | |
wait = (ms) => { | |
var start = new Date().getTime(); | |
var end = start; | |
while(end < start + ms) { | |
end = new Date().getTime(); | |
} | |
} | |
// if page error, reload | |
if (document.querySelector('.cf-wrapper.cf-error-overview')) { | |
window.setTimeout(()=>{ | |
location.reload(); | |
}, 3000); | |
} | |
// fullscreen trigger | |
var alreadyFull = false; | |
key_press = (e) => { | |
var type = e.target.getAttribute('type'); | |
var tag = e.target.tagName.toLowerCase(); | |
var modal = document.querySelector('.manga-viewer-modal').style.display; | |
if(type != 'text' && tag != 'textarea' && type != 'search'){ | |
if (modal !== 'flex') { | |
// for check full screen > none | |
switch(e.keyCode){ | |
case 70: //f | |
document.querySelector('a.show_viewer').click(); | |
wait(500); | |
document.querySelector('div.buttons i.fa-square').click(); | |
wait(100); | |
document.querySelector('div.buttons i.fa-expand').click(); | |
break; | |
case 38:// up arrow | |
document.querySelector('a.show_viewer').click(); | |
wait(500); | |
document.querySelector('div.buttons i.fa-square').click(); | |
wait(100); | |
document.querySelector('div.buttons i.fa-expand').click(); | |
break; | |
case 32: //space | |
if (!alreadyFull) { | |
document.querySelector('a.show_viewer').click(); | |
wait(500); | |
document.querySelector('div.buttons i.fa-square').click(); | |
wait(100); | |
document.querySelector('div.buttons i.fa-expand').click(); | |
} else { | |
document.querySelector('a.chapter_next').click(); | |
// alreadyFull = false; // already refresh | |
} | |
break; | |
case 37: // left arrow | |
document.querySelector('a.chapter_prev').click(); | |
break; | |
case 39: // right arrow | |
document.querySelector('a.chapter_next').click(); | |
break; | |
default: | |
} | |
} else { | |
// when full screen | |
switch(e.keyCode){ | |
case 32: //space | |
e.preventDefault(); | |
if (!alreadyFull) { | |
alreadyFull = true; | |
} else { | |
console.log('이미 전체화면 한번 됨 추가 true로 변경', alreadyFull); | |
} | |
document.querySelector('div.page-btn.right').click(); | |
break; | |
default: | |
} | |
} | |
} | |
}; | |
window.addEventListener('keydown', (e) => key_press(e), false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment