Auto All Page

Otomatis menampilkan semua halaman artikel berita dalam 1 page

当前为 2021-01-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Auto All Page
  3. // @version 1.6.0
  4. // @author reforget-id
  5. // @namespace autoallpage
  6. // @icon https://www.iconsdb.com/icons/download/orange/pages-1-256.png
  7. // @homepage https://github.com/reforget-id/AutoAllPage
  8. // @description Otomatis menampilkan semua halaman artikel berita dalam 1 page
  9. // @include http*://*.detik.com/*
  10. // @include http*://*.kompas.com/*
  11. // @include http*://*.tribunnews.com/*
  12. // @include http*://*.merdeka.com/*
  13. // @include http*://*.suara.com/*
  14. // @include http*://*.matamata.com/*
  15. // @include http*://*.sindonews.com/*
  16. // @include http*://*.inews.id/*
  17. // @include http*://*.grid.id/*
  18. // @include http*://*.bolasport.com/*
  19. // @include http*://*.motorplus-online.com/*
  20. // @include http*://*.gridoto.com/*
  21. // @include http*://*.pikiran-rakyat.com/*
  22. // @include http*://*.kontan.co.id/*
  23. // @include http*://akurat.co/*
  24. // @include http*://m.akurat.co/*
  25. // @include http*://*.kompasiana.com/*
  26. // @run-at document-start
  27. // ==/UserScript==
  28.  
  29.  
  30. (() => {
  31.  
  32. const url = window.location.href
  33. const regex = {
  34. detik: /(?<=^.+\.detik\.com\/[a-z-]+\/d-\d+\/.+)((?<!\?.*|\/\d*)|\?.*(?<!\?single=1)|\/\d*)$/,
  35. kompas: /(?<=^.+\.kompas.com\/([a-z-]+\/|)read\/\d{4}\/\d{2}\/\d{2}\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all(#page\d+|))|\/)$/,
  36. tribun: /(?<=^.+.tribunnews.com\/([a-z-]+\/|)\d{4}\/\d{2}\/\d{2}\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  37. merdeka: /(?<=^.+\.merdeka\.com\/[a-z-]+\/.+\.html)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  38. suara: /(?<=^.+\.(suara|matamata)\.com\/[a-z-]+\/\d{4}\/\d{2}\/\d{2}\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  39. sindo: /(?<=^.+\.sindonews\.com\/read\/\d+\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?showpage=all)|\/\d*)$/,
  40. inews: /(?<=^.+\.inews\.id\/(berita|[a-z-]+\/[a-z-]+)\/.+)((?<!\?.*|\/(all.*|\d*))|(\/all.+)|\/\d*|\?.*)$/,
  41. grid: /(?<=^.+\.(grid\.id|(motorplus-online|gridoto|bolasport)\.com)\/read\/\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  42. pr: /(?<=^.+\.pikiran-rakyat\.com\/[a-z-]+\/pr-\d+\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  43. kontan: /(?<=^.+\.kontan\.co\.id\/news\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  44. akurat: /(?<=^.+akurat\.co\/[a-z-]+\/id-\d{7}-.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  45. mAkurat: /(?<=^.+m\.akurat\.co\/id-\d{7}-.+)((?<!\?.*|\/)|\?.*(?<!\?page=all)|\/)$/,
  46. kompasiana: /(?<=^.+\.kompasiana\.com\/.+\/[a-z0-9]{24}\/.+)((?<!\?.*|\/)|\?.*(?<!\?page=all(#sectionall|))|\/)$/
  47. }
  48.  
  49. for (i in regex) {
  50. let urlMatcher = url.match(regex[i])
  51. if (urlMatcher) {
  52. redirector(i)
  53. break
  54. }
  55. }
  56.  
  57. function redirector(patternName) {
  58. let replacer, newUrl
  59.  
  60. if (patternName == 'detik') {
  61. replacer = '?single=1'
  62. } else if (patternName == 'sindo') {
  63. replacer = '?showpage=all'
  64. } else if (patternName == 'inews') {
  65. replacer = '/all'
  66. } else {
  67. replacer = '?page=all'
  68. }
  69.  
  70. newUrl = url.replace(regex[patternName], replacer)
  71. console.log(`EXECUTE [${patternName}] REDIRECT`)
  72. window.location.href = newUrl
  73. return
  74. }
  75.  
  76. })()