Last active
August 7, 2023 06:10
-
-
Save erhaem/cd0446d92f602beec36486f11b1a558a to your computer and use it in GitHub Desktop.
Tired of shitty Indonesian News sites' page-splitting? This tool allows you to deal with it by redirecting you to the entire content page. You may use this tool with Greasemonkey or alike, or even putting it on bookmark bar (Bookmarklet) by putting "javascript:" before the whole script.
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
| /** | |
| * Indonesian News Sites' Page-splitting Deterrent Tool | |
| * @author Rifqi Haidar | |
| */ | |
| (function () { | |
| const averageParam = "?page=all"; | |
| // pattern: { domainName: endpoint??params } | |
| const sites = { | |
| "detik.com": "?single=1", | |
| "grid.id": averageParam, | |
| "gridoto.com": averageParam, | |
| "hukumonline.com": averageParam, | |
| "jawapos.com": averageParam, | |
| "kompas.com": averageParam, | |
| "kontan.co.id": averageParam, | |
| "merdeka.com": averageParam, | |
| "motorplus-online.com": averageParam, | |
| "suara.com": averageParam, | |
| "viva.co.id": averageParam, | |
| "tribunnews.com": averageParam | |
| }; | |
| // defines pure article URL | |
| const urlWithNoParams = location.href.split("?")[0]; | |
| if (!urlWithNoParams) { | |
| alert("You're on home page, perhaps."); | |
| return | |
| } | |
| // defines domain name | |
| const domainName = location.hostname.split(".") | |
| .slice(-2) | |
| .join("."); | |
| const isThisSiteSupported = Object.keys(sites).indexOf(domainName) > -1; | |
| if (!isThisSiteSupported) { | |
| alert("This site is not supported!"); | |
| return | |
| } | |
| location.href = urlWithNoParams + sites[domainName]; | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment