Show All News

Show News From All Pages

As of 2020-07-09. See the latest version.

// ==UserScript==
// @name        Show All News
// @namespace   https://greasyfork.org/en/users/37676
// @description Show News From All Pages
// @match       *://*.kompas.com/*
// @exclude     *://*.kompas.com/komentar*
// @match       *://*.detik.com/*
// @match       *://*.tribunnews.com/*
// @run-at      document-start
// @version     1.0.2
// @grant       none
// @noframes
// @license     Creative Commons Attribution 4.0 International Public License; http://creativecommons.org/licenses/by/4.0/
// ==/UserScript==

var siteInfo = [
    ['kompas.com','page','all'],
    ['detik.com','page','all'],
	['tribunnews.com','page','all']
];

var siteHost = window.location.hostname;
var siteLength = siteInfo.length;
var siteIndex = -1;

for(var i = 0; i < siteLength; i++)
{
	if (siteHost.indexOf(siteInfo[i][0]) > -1)
	{
		siteIndex = i;
		break;
	}
}

if (siteIndex > -1)
{
	var link = new URL(window.location.href);
	var isRedirect = false;
	
	if (link)
	{
		var pageParam = link.searchParams.get(siteInfo[siteIndex][1]);
		
		if (pageParam)
		{
			if (pageParam != siteInfo[siteIndex][2])
			isRedirect = true;
		}
		
		else
		isRedirect = true;
		
		if (isRedirect)
		{
			link.searchParams.set(siteInfo[siteIndex][1], siteInfo[siteIndex][2]);
			
			if (siteInfo[i][0] == 'detik.com')
			link.searchParams.set('single', '1');
			
			window.location.replace(link.href);
		}
	}
}