Last active
June 24, 2016 15:33
-
-
Save hobbes78/c9cbbc33aef6b6b8f84e to your computer and use it in GitHub Desktop.
Requests a single page news article instead of one split across several pages
This file contains 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
// ==UserScript== | |
// @name Single page redirector | |
// @namespace https://gist.github.com/hobbes78/c9cbbc33aef6b6b8f84e | |
// @version 1.5 | |
// @description enter something useful | |
// @author hobbes78 | |
// @match http://*.publico.pt/* | |
// @match https://*.publico.pt/* | |
// @grant none | |
// @include http://*.publico.pt/* | |
// @include https://*.publico.pt/* | |
// @run-at document-start | |
// ==/UserScript== | |
if (window.location.href.endsWith("-1") | |
|| !window.location.host.endsWith("publico.pt")) | |
{ | |
return; | |
} | |
var oldUrlPath = window.location.href; | |
var strTemplate = /.*[0-9]+.*$/; | |
var sepChar = "&"; | |
if (window.location.host.endsWith("publico.pt")) | |
{ | |
if (window.location.host == "blogues.publico.pt" | |
|| window.location.host == "inimigo.publico.pt" | |
|| window.location.host == "p3.publico.pt") | |
{ | |
return; | |
} | |
sepChar = "?"; | |
var pos = oldUrlPath.indexOf('?'); | |
if (pos != -1) | |
{ | |
oldUrlPath = oldUrlPath.substring(0, pos); | |
} | |
strTemplate = /https?:\/\/[a-z]+.publico\.pt\/.*\/noticia\/.*[0-9]+.*$/; | |
} | |
var fullPageSwitch = sepChar + "page="; | |
if (window.location.host == "fugas.publico.pt") | |
{ | |
strTemplate = /.+\/.+\/.+$/; | |
fullPageSwitch = "?pagina="; | |
} | |
else if (window.location.host == "lifestyle.publico.pt") | |
{ | |
strTemplate = /.+\/.+\/.+$/; | |
fullPageSwitch = "/"; | |
} | |
if (oldUrlPath.match(strTemplate)) | |
{ | |
var newUrlPath = oldUrlPath + fullPageSwitch + "-1"; | |
window.location.replace(newUrlPath); | |
} |
Instruções para ativar no Firefox:
- Instalar extensão Greasemonkey
- Clicar no botão "Raw" nesta página e confirmar que desejam instalar o script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instruções para ativar no Chrome: