Surrogate for repubblica.it

Ask for help about NoScript, no registration needed to post
ginola

Surrogate for repubblica.it

Post by ginola »

Hi guys,

I can read the website of Italian newspaper Repubblica with scripts disabled with no problem, unless I want to browse their galleries. (example).

As you can see, there's a parameter in the URL pointing to the position of the current picture. I can simply increment that, and it brings me to the next one, so I think the JS is really simple too.

Is somebody able to write a surrogate script that enables browsing galleries?

Thanks!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0
User avatar
Giorgio Maone
Site Admin
Posts: 9557
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Surrogate for repubblica.it

Post by Giorgio Maone »

Code: Select all

for (let a of document.querySelectorAll("a[href^='javascript:show']")) a.href = location.href.replace(/\/(\d+)\/?(?:#|$)/, function(m, s) "/" + (parseInt(s) + (/Next/.test(a.href) ? 1 : -1)))
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
ginola

Re: Surrogate for repubblica.it

Post by ginola »

Thanks Giorgio!

And what should the

Code: Select all

sources
be? I've tried

Code: Select all

@*.repubblica.it
but it didn't work.

Is there a FAQ entry on how to write surrogates?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0
User avatar
Giorgio Maone
Site Admin
Posts: 9557
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Surrogate for repubblica.it

Post by Giorgio Maone »

ginola wrote:And what should the

Code: Select all

sources
be? I've tried

Code: Select all

@*.repubblica.it
but it didn't work.
"@" is for surrogates running on JavaScript enabled pages.

If you want a surrogate to run on a JavaScript disabled page, you need to prepend it with "!",like

Code: Select all

!.repubblica.it
ginola wrote:Is there a FAQ entry on how to write surrogates?
A blog post.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
User avatar
Giorgio Maone
Site Admin
Posts: 9557
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Surrogate for repubblica.it

Post by Giorgio Maone »

BTW, I slightly adjust the script to handle some edge cases:

Code: Select all

let last = document.head.textContent.match(/\blastPhoto\s*=\s*(\d+)/); last = last && parseInt(last[1]); for (let a of document.querySelectorAll("a[href^='javascript:show']")) a.href = location.href.replace(/\/(\d+)(?=\/?(?:[?#]|$))/, function(m, s) { let n = parseInt(s) + (/Next/.test(a.href) ? 1 : -1); if (n < 1) n = last || 1; else if (last && n > last) n = 1; return "/" + n})
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
Post Reply