[TS] Linx Amender

Generic tracking/redirection/open-in-new-tab removal; Amend page title; URL redirector; and more power functionality. Has rules for Pixiv, deviantArt, twitter, youtube, blogger, Batota etc.

< Feedback on [TS] Linx Amender

Question/comment

§
Posted: 2016-10-20
Edited: 2016-10-20

Help with scripting

I would like to write a script that redirects all wikia links to the monobook theme, so 'example.wikia.com/wiki/Example' becomes 'example.wikia.com/wiki/Example?useskin=monobook'. I couldn't understand the regex rules, can you please help?
On a side note, is it possible to implement a system using asterisks as wildcards (so in this case 'example.wikia.com/wiki/*' to 'example.wikia.com/wiki/*?useskin=monobook')? I see this system being used in a lot of places (tampermonkey and stylish both use them). It would make beginners write new rules much more easily.

TimidScriptAuthor
§
Posted: 2016-10-21
Edited: 2016-10-21

The asterisks system is rather limited and to be frank useless unless I implement background code to allow behavior similar to what already exists in RegEx. Not really worth the effort.

RegEx101 is a good site with a quick reference section. It's pretty easy to get the basics down.

The rules expressions:

Expression 1:
We need to first create an expression that makes sure "?useskin=monobook" is already added, if it is clean it. We do this to avoid infinite redirection because keep on adding "?useskin=monobook" at the end.

Search: \?useskin=monobook
Replace: nothing (empty string)

Expression 2:
Second expression we just append "?useskin=monobook" a the end.

Search: (.+)
Replace: $1?useskin=monobook


The rule which you can import in LA3. Just copy it and use the "Paste Rules" button.

{"id":"L1477055121855","name":"Wikia: Use Monobook Skin","URLs":"@.wikia.com/","description":"Forces the use of monobook skin for wikia pages","sampleURL":"http://superhot.wikia.com/wiki/SUPERHOT_Wiki","nthNode":"0","type":3,"selectors":"a","regexes":[{"search":"\\?useskin=monobook"},{"search":"(.+)","replace":"$1?useskin=monobook"}],"enabled":true,"timestamp":1477055405815}

Screenshot of the actual rule.

§
Posted: 2016-10-21

I see, I think I'll look up a bit more about regex for future purposes. Thanks!

Post reply

Sign in to post a reply.