Stumped by single page

in Script development
Subscribe to Stumped by single page 3 posts, 2 voices

rseiler User

After the script here, dated Oct 27, 2011:

became outdated last fall due to a site revamp, I had to rework it myself when the author wouldn't respond. I posted it in the Issues section of that script at the time:

// ==UserScript==
// @name           Slate Single Page View (re-fixed)
// @namespace      
// @description    Automatically redirects article URLs to a single page version if available.
// @include*
// ==/UserScript==

// Get the current window location (URL)
var curLoc = window.location.href;

// Get the html text
var bodyText = document.body.textContent;

if (curLoc.indexOf("single.html") == -1) { //Make sure it's not already singlepage

	if (bodyText.indexOf("SINGLE PAGE") != -1) { //Does it think could be repaginated?

			var newLoc = curLoc.replace(".html", ".single.html"); //Changes URL to single-page form
			window.location.replace(newLoc); //Loads the new page

And that was working through last weekend, when it suddenly stopped working, not just in Firefox but Opera.

Does anyone know why? Something about the site must have changed to break it, since nothing changed on my end, but I don't know what. The URL format is unchanged. As a test, I even tried getting rid of the conditional lines temporarily so that it would always run, but no go. The conditional logic is not what's tripping it up. It's something with the other lines.

Test URL on the site, but any multi-page article will do:

ms98 Scriptwright

to load new page:

var newLoc = curLoc.replace(".html", ".single.html"); //Changes URL to single-page form
window.location.href = newLoc; //Loads the new page

rseiler User