Skip to content

Instantly share code, notes, and snippets.

@hobbes78
Last active June 24, 2016 15:33
Show Gist options
  • Save hobbes78/c9cbbc33aef6b6b8f84e to your computer and use it in GitHub Desktop.
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
// ==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);
}
@hobbes78
Copy link
Author

Instruções para ativar no Chrome:

  • Instalar a extensão Tampermonkey
  • Nesta página, clicar no botão "Raw" e a seguir em "Install"

@hobbes78
Copy link
Author

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