// ==UserScript==
// @name コミックDAYS&くらげバンチ&マガポケ&ジャンプ+&となりのヤングジャンプ&WEBヒーローズ&Pixivコミック 左キーだけでどんどん読む
// @description 「次の話を読む」や「この作品の無料公開中の話へ」ボタンが出た時に左キーでそれをクリックします Enterで最新話に移動 fや[で全画面化
// @match *://comic-days.com/episode/*
// @match *://kuragebunch.com/episode/*
// @match *://pocket.shonenmagazine.com/episode/*
// @match *://shonenjumpplus.com/episode/*
// @match *://tonarinoyj.jp/episode/*
// @match *://viewer.heros-web.com/episode/*
// @match *://comic.pixiv.net/viewer/*
// @match *://mangacross.jp/comics/*
// @match *://comic-action.com/episode/*
// @match *://ashitano.tonarinoyj.jp/series/*
// @match *://daysneo.com/works/*
// @match *://rookie.shonenjump.com/series/*
// @match *://kodansha-cc.co.jp/comic/*
// @match *://viewer.ganganonline.com/manga/*
// @match *://www.mangabox.me/reader/*
// @match *://r-cbs.mangafactory.jp/*
// @match *://comic-gardo.com/episode/*
// @match *://comic-zenon.com/episode/*
// @match *://magcomi.com/episode/*
// @match *://curazy.com/manga/viewer*
// @match *://comic-trail.jp/pt/*
// @match *://piccoma.com/web/viewer/*
// @match *://wanibooks-newscrunch.com/articles/viewer/*
// @match *://urasunday.com/title/*
// @match *://feelweb.jp/episode/*
// @match *://www.sunday-webry.com/episode/*
// @match https://comicborder.com/episode/*
// @run-at document-idle
// @grant GM_addStyle
// @version 0.6.13
// @namespace https://greasyfork.org/users/181558
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @require https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
// ==/UserScript==
(function() {
const KeyNextReadableEpisode = "ArrowLeft";
const KeyLatestReadableEpisode = "Enter";
const KeyFullScreen1 = "[";
const KeyFullScreen2 = "f";
setInterval(() => {
var ele = elegeta('//section[@class="read-more-container"]/button|//button[@class="js-read-more-button"]|//div[@class="series-comment-contents-box"]/button|//ul[@class="backnumber-list"]/li/a/span').find(e => isinscreen(e, "wait"));
$(ele).click().effect("highlight");
}, 1500); // アコーディオンを開く
// 次の話に←表示
var nextl = '//div[@class="viewer-colophon-info-wrapper"]/div[@class="viewer-colophon-info"]/p[@class="viewer-colophon-next-episode"]/a[@class="next-link test-back-matter-next-link"]|//a[contains(@class,"next-episode-free-link common-button")]|//a[@class="next-open-link"]|//a[contains(text(),"次の話")]|//div[@class="end-page__box"]/div[2]/a[contains(text(),"次のエピソードを読む")]|//li/a[@class="ui-button-colophon js-next-episode"]|//div[@id="end_page"]/p/a/span[contains(text(),"次の話へ")]|//a[@class="button next-episode-button"]|//a[@class="btn btn-next" and text()="次の話を読む"]|//div/button[contains(text(),"次の話へ")]|//a[@class="lastSlider_nextButton"]|//div[@id="rc_next"]|//a[@class="viewer_commonButton viewer_commonButton-gotoNext jsViewer_commonButton"]|//div[@class="r-linkbutton_orange r-main"]/a[contains(text(),"次の話を読む")]|//div[@class="article-comic-slider__item-next"]/div/a[contains(text(),"次の話を読む")]|//a[@class="next-episode-free-link common-button"]';
var leftArrowTimer = setInterval(() => {
var ele = eleget0(nextl);
if (isinscreen(ele) && !ele.innerText.match(/ \(←\)/)) {
ele.innerText += " (←)";
}
}, 500);
// 最新話にEnter表示
var lastl = '//div[@class="js-readable-product-list"]/div[1]/ul[1]/li[1]/a/div/h4|//div[@class="js-readable-product-list"]/ul[1]/li[1]/a/div/h4|//div[2]/ul[1]/li[1]/a/div[2]/h4[@class="series-episode-list-title"]';
var lastl2 = '//span[@class="test-readable-product-is-free series-episode-list-is-free"]'
var writeEnter = setInterval(() => {
var ele = eleget0(lastl2) || eleget0(lastl);
if (!eleget0('//*[contains(text()," (Enter)")]|//section[@class="read-more-container"]/button|//button[@class="js-read-more-button"]') && isinscreen(ele, "wait")) ele.innerText += " (Enter)"; // clearInterval(writeEnter);
}, 500);
// 1,下にスクロールさせてエピソードリンクを読み込ませる
setTimeout(() => {
var ele = eleget0('//div[@class="episode-header-container"]');
// if (ele) ele.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
if (ele) {
$("html,body").animate({ scrollTop: $(ele).offset().top });
}
}, 500);
// 2,一番上にスクロールを戻す
setTimeout(() => {
$(eleget0('//div[@id="btn-scale"]/div[1]/div[text()="拡大"]|//span[@class="viewer-btn-expand js-viewer-btn-expand"]|//button[@class="viewer-button viewer-button--max"]/img')).click(); // 「拡大」ボタンがあれば押す
$("html,body").animate({ scrollTop: 0 });
}, 1600)
document.addEventListener('keydown', function(e) {
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA' && e.target.getAttribute('contenteditable') != 'true') {
// if (/input|textarea/i.test(e.target.tagName) == false) {
if (!e.getModifierState("Alt") && !e.getModifierState("Control") && !e.getModifierState("Shift") && e.key === KeyNextReadableEpisode) { // 左キー
var ele = eleget0(nextl);
if (isinscreen(ele)) {
lightup();
ele.click();
ele.focus();
ele.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
// if(ele.href) location.href = ele.href;
}
}
if (!e.getModifierState("Alt") && !e.getModifierState("Control") && !e.getModifierState("Shift") && e.key === KeyLatestReadableEpisode) { // Enterキー
var ele = eleget0(lastl2) || eleget0(lastl);
if (ele) {
lightup();
ele.parentNode.parentNode.click();
ele.parentNode.parentNode.focus();
ele.parentNode.parentNode.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
// if(ele.href) location.href = ele.href;
} else eleget0('//div[@class="episode-header-container"]') && eleget0('//div[@class="episode-header-container"]').scrollIntoView();
}
if (!e.getModifierState("Alt") && !e.getModifierState("Control") && !e.getModifierState("Shift") && e.key === "a") { // a::
domsort(eleget0('//ul[@class="series-comment-contents-list js-series-comment-list"]'), elegeta('//li[@class="comment-container js-series-report-comment-container"]'), v => parseInt(eleget0('//span[@class="comment-likes-number js-comment-like-counts"]|.//span[@class="comment-likes-number js-comment-like-counts comment-like-counts-zero"]', v)?.innerText))
}
if (!e.getModifierState("Alt") && !e.getModifierState("Control") && !e.getModifierState("Shift") && (e.key === KeyFullScreen1 || e.key === KeyFullScreen2)) { // f [ 全画面化
var y = window.pageYOffset;
if (!document.fullscreenElement) {
let p = document.documentElement.requestFullscreen();
p.catch(() => {});
} else {
if (document.exitFullscreen) {
let p = document.exitFullscreen();
p.catch(() => {});
}
}
setTimeout(window.scroll, 100, 0, y);
}
}
}, false);
return
function elegeta(xpath, node = document) {
if (!xpath) return [];
let flag
if (!/^\.?\//.test(xpath)) return /:visible$/.test(xpath) ? [...node.querySelectorAll(xpath.replace(/:visible$/, ""))].filter(e => e.offsetHeight) : [...node.querySelectorAll(xpath)]
try {
var array = [];
var ele = document.evaluate("." + xpath.replace(/:visible$/, ""), node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
let l = ele.snapshotLength;
for (var i = 0; i < l; i++) array[i] = ele.snapshotItem(i);
return /:visible$/.test(xpath) ? array.filter(e => e.offsetHeight) : array;
} catch (e) { popup3(e + "\n" + xpath, 1); return []; }
}
function eleget0(xpath, node = document) {
if (!xpath) return null;
if (!/^\.?\//.test(xpath)) return node.querySelector(xpath.replace(/:visible$/, ""));
try {
var ele = document.evaluate("." + xpath.replace(/:visible$/, ""), node, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
return ele.snapshotLength > 0 ? ele.snapshotItem(0) : "";
} catch (e) { popup3(e + "\n" + xpath, 1); return null; }
}
function isinscreen(ele, wait = "nowait") {
if (!ele || (wait == "wait" && $(eleget0('//span[@class="loading-text"]')).is(":visible"))) return 0;
var eler = ele.getBoundingClientRect();
return (eler.top > 0 && eler.left > 0 && eler.left < window.parent.screen.width && eler.top < window.parent.screen.height);
}
function lightup() {
GM_addStyle(":focus { box-shadow: 0px 0px 10px 10px rgba(0, 250, 0, 0.5), inset 0 0 100px rgba(0, 250, 0, 0.2) !important; outline: rgba(0, 250,0,0.7) solid 4px !important; outline-offset: 1px !important; }")
setTimeout(() => GM_addStyle(":focus { box-shadow: 0px 0px 0px 0px rgba(0, 250, 0, 0.5),inset 0 0 0px rgba(0, 250, 0, 0.2) !important; outline: rgba(0, 0,0,0) solid 0px !important;}"), 1000);
}
function domsort(container, doms, func, prepend = 0) { // prepend:1ならcontainerの最初に付ける、0なら最後に付ける
doms.map(function(v) { return { dom: v, value: func(v) } }).sort(function(a, b) { return (typeof Number(a.value) && Number(b.value) ? (b.value - a.value) : (a.value < b.value ? 1 : -1)) }).forEach(function(v) { prepend ? container.prepend(v.dom) : container.appendChild(v.dom); });
}
})();