wered ad network for devs. Get your message in front of the right developers with EthicalAds.
Ads by EthicalAds
// ==UserScript==
// @name arca.live page mover
// @namespace Violentmonkey Scripts
// @match https://arca.live/*
// @grant none
// @version 1.0.3.7
// @author 7r
// @license MIT
// @description 2023. 5. 14. 오후 4:58:27
// ==/UserScript==
(()=>{
function getMovedPage(url, direction) {
if (!url.includes("/write")) {
url.includes("#") && (url = url.split("#")[0]);
const [paths, queryString] = url.split('?');
const path = paths.split("/").filter(part => part && !part.includes(":"));
const queryParams = queryString ? Object.fromEntries(new URLSearchParams(queryString)) : {};
let openedPosting = path[3] && (path.splice(3, 2), true);
let numPage = parseInt(queryParams["p"]);
if (((!numPage || numPage === 1) && direction) && !openedPosting) {
alert("첫페이지 입니다.");
} else {
queryParams["p"] = numPage && openedPosting ? numPage : direction ? (numPage - 1 || 1) : (numPage + 1) || (openedPosting || direction ? 1 : 2);
const updatedQueryString = new URLSearchParams(queryParams).toString();
location.href = `https://${path.join("/")}?${updatedQueryString}`;
}
}
}
function isInputElement(event) {
return ['INPUT', 'TEXTAREA'].includes(event.target.nodeName) || event.target.classList.contains('fr-element');
}
document.addEventListener('keydown', function (event) {
if (isInputElement(event) || event.altKey || event.ctrlKey || event.shiftKey || [16, 17, 18].includes(event.keyCode)) return;
const isLeftArrow = event.keyCode === 37;
const isRightArrow = event.keyCode === 39;
if (isLeftArrow || isRightArrow) {
getMovedPage(document.location.href, isLeftArrow);
event.preventDefault();
}
});
})();