1

Sorry for the disastrous title, it's hard to concisely phrase what I need.

I'm writing a userscript.

I want the userscript to only apply to specific parts of a website, but the part I want isn't at the beginning of the URL so I can't do URL starts with:.

I know I can use URLs matching the regular expression: instead, but I don't know how to write that so it selects the part I'm after.

The part of the URL I want to isolate is at the very end.

I've been searching for days. No example I find works for me.

The URL looks like this:

http://www.website.com/some/extra/words/seriously-lots/of/more/stuff/page=3

I want to isolate any page after 1. The userscript should not activate on page 1. Only pages after it. So I'm looking for something that will isolate page=(>1) but I don't know if that exists.

Antimoany
  • 75
  • 1
  • 9
  • I don't know Stylish, so what exactly is it that you need? A regex matching to that exact URL with numbers greater than 1? – Pinkie Pie Feb 27 '19 at 07:39
  • @PinkiePie I'm actually using STYLUS, but stackoverflow wouldn't let me use that tag, or several other tatgs that would have been far more specific and helpful than the ones it did allow. Didn't know hitting enter would send, that's annoying. It can't be the exact URL, because the stuff between .com/ and the /page= changes, too. I need something that can look at the domain, and then check the number at the end of the URL is greater than 1, without needing to know the exact URL. I can link to the exact site if that would help? – Antimoany Mar 07 '19 at 13:59
  • Yeah, that would probably help in figuring out what regex you need. – Pinkie Pie Mar 07 '19 at 17:29
  • @PinkiePie Alright, here's an example: https://toyhou.se/~forums/14.suggestions-bugs/38498.-read-to-do-list?page=1 That's one thread on the forums. Here's another: https://toyhou.se/~forums/11.general/14896.a-newcomer-s-guide-introduction-board?page=31 The only thing that's consistent is the domain, and the page numbers at the end. – Antimoany Mar 07 '19 at 21:27
  • This regex should work: `.*toyhou\.se\/.+page=[2-9][0-9]*` It will match [ANYTHING or NOTHING]toyhou.se/[ANYTHING]page=[Number greater than 1] – Pinkie Pie Mar 08 '19 at 22:32
  • @PinkiePie That works exactly the way I need it to, thank you so much! Is there some way I can reward you? I'm unfamiliar with stackoverflow's karma system. – Antimoany Mar 09 '19 at 11:12
  • I will post it in an answer, then you can accept the answer - this will also mark the question as answered for anyone else stumbling across it. – Pinkie Pie Mar 10 '19 at 15:39

2 Answers2

1

Based on further details in the comments this is a regex that finds all pages > 1 on the given website as required:

 .*toyhou\.se\/.+page=[2-9][0-9]* 

It will match [ANYTHING or NOTHING]toyhou.se/[ANYTHING]page=[Number greater than 1]

Pinkie Pie
  • 688
  • 7
  • 15
-1

I use something similar to this. You could try:

$url = $_SERVER['REQUEST_URI']; 
$explode = explode('=', $url);  
$page =$explode[1]; 

if($page >= 2){ 
//do something

} 

There may be a better way but this should work.

John
  • 7
  • 5