Auto All Page

Otomatis menampilkan semua halaman artikel berita dalam 1 page

当前为 2020-11-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Auto All Page
// @version       1.4.0
// @author        reforget-id
// @namespace     autoallpage
// @icon          https://www.iconsdb.com/icons/download/orange/pages-1-256.png
// @homepage      https://github.com/reforget-id/AutoAllPage
// @description   Otomatis menampilkan semua halaman artikel berita dalam 1 page
// @include       http*://*.detik.com/*
// @include       http*://*.kompas.com/*
// @include       http*://*.tribunnews.com/*
// @include       http*://*.merdeka.com/*
// @include       http*://*.suara.com/*
// @include       http*://*.matamata.com/*
// @include       http*://*.sindonews.com/*
// @include       http*://*.inews.id/*
// @include       http*://*.grid.id/*
// @include       http*://*.bolasport.com/*
// @include       http*://*.motorplus-online.com/*
// @include       http*://*.gridoto.com/*
// @include       http*://*.pikiran-rakyat.com/*
// @include       http*://*.kontan.co.id/*
// @run-at        document-start
// ==/UserScript==


function consts() {
    const data = {
        detikRegex : /(?<=^.+\.detik\.com\/[a-z-]+\/d-\d+\/.+)((?<!\?.*|\/\d*)|\?.*(?<!\?single=1)|\/\d*)$/,
        kompasRegex : /(?<=^.+\.kompas.com\/([a-z-]+\/|)read\/\d{4}\/\d{2}\/\d{2}\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all(#page\d+|))|\/)$/,
        tribunRegex : /(?<=^.+.tribunnews.com\/([a-z-]+\/|)\d{4}\/\d{2}\/\d{2}\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
        merdekaRegex : /(?<=^.+\.merdeka\.com\/[a-z-]+\/.+\.html)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
        suaraRegex : /(?<=^.+\.(suara|matamata)\.com\/[a-z-]+\/\d{4}\/\d{2}\/\d{2}\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
        sindoRegex : /(?<=^.+\.sindonews\.com\/read\/\d+\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?showpage=all)|\/\d*)$/,
        inewsRegex : /(?<=^.+\.inews\.id\/(berita|[a-z-]+\/[a-z-]+)\/.+)((?<!\?.*|\/(all.*|\d*))|(\/all.+)|\/\d*|\?.*)$/,
        gridRegex : /(?<=^.+\.(grid\.id|(motorplus-online|gridoto|bolasport)\.com)\/read\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
        prRegex : /(?<=^.+\.pikiran-rakyat\.com\/[a-z-]+\/pr-\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
        kontanRegex : /(?<=^.+\.kontan\.co\.id\/news\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/
    }

    return data
}


async function urlRedirect() {
    const url = window.location.href

    detikRedirect(url)
    kompasRedirect(url)
    tribunnewsRedirect(url)
    merdekaRedirect(url)
    suaraRedirect(url)
    sindonewsRedirect(url)
    inewsRedirect(url)
    gridRedirect(url)
    pikiranRakyatRedirect(url)
    kontanRedirect(url)
}

function redirectHelper(url, regex, replacer) {
    let matcher = url.match(regex)
    if (matcher) {
        let newUrl = url.replace(regex, replacer)
        console.log('EXECUTE REDIRECT')
        window.location.href = newUrl
        return
    }
}

/*
function ampRemover(a, ampRegex, replacer) {
	let url = a.getAttribute("href")
	let matcher = url.match(ampRegex)
	if (matcher) {
		let newUrl = url.replace(regex, replacer)
		a.setAttribute('href', newUrl)
	}
}
*/


function detikRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().detikRegex, '?single=1')
        console.log('detik redirect')
    })
}

function kompasRedirect(url) {
    new Promise(() => {
        //let ampRegex = /(^.+(amp(\/s\/\w+|)))(?<!\.kompas.com\/(\w*(\/|))read\/\d+\/\d+\/\d+\/\d+\/.+$)/
        //ampRemover(a, ampRegex, 'https://www')
        redirectHelper(url, consts().kompasRegex, '?page=all')
        console.log('kompas redirect')
    })
}

function tribunnewsRedirect(url) {
    new Promise(() => {
        //let ampRegex = /(^.+(amp\/s\/))(?<!\.tribunnews.com\/(\w*(\/|))\d+\/\d+\/\d+\/.+)/
        redirectHelper(url, consts().tribunRegex, '?page=all')
        console.log('tribun redirect')
    })
}

function merdekaRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().merdekaRegex, '?page=all')
        console.log('merdeka redirect')
    })
}

function suaraRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().suaraRegex, '?page=all')
        console.log('suara redirect')
    })
}

function sindonewsRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().sindoRegex, '?showpage=all')
        console.log('sindo redirect')
    })
}

function inewsRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().inewsRegex, '/all')
        console.log('inews redirect')
    })
}

function gridRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().gridRegex, '?page=all')
        console.log('grid redirect')
    })
}

function pikiranRakyatRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().prRegex, '?page=all')
        console.log('pikiran rakyat redirect')
    })
}

function kontanRedirect(url) {
    new Promise(() => {
        redirectHelper(url, consts().kontanRegex, '?page=all')
        console.log('kontan redirect')
    })
}


urlRedirect()