Skip to content

Instantly share code, notes, and snippets.

@erhaem
Last active August 7, 2023 06:10
Show Gist options
  • Select an option

  • Save erhaem/cd0446d92f602beec36486f11b1a558a to your computer and use it in GitHub Desktop.

Select an option

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.
/**
* 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