MozillaZine

Redirect mobile links to desktops when on desktop

User Help for Mozilla Firefox
slickrcbd
 
Posts: 378
Joined: September 1st, 2010, 1:57 am

Post Posted September 20th, 2019, 11:18 pm

There is a Greasemonkey script called "Redirect Userscripts.org to Userscripts-MIRROR.org". It was useful during the transition when userscript.org went off-line and somebody put up a read-only mirror site.
It does exactly what it says in the name.
However, I've tried to copy that script to automatically change links to m.fanfiction.net to www.fanfiction.net, yet it does not work. I've copied everything and only changed the references to userscript.org to m.fanfiction.net and the references to userscripts-mirror.org to www.fanfiction.net.

Is there any kind of add-on that would do something similar? Intercept links to mobile versions and redirect me to the desktop version? Otherwise, I could post both versions of the script and maybe somebody could tell me what I did wrong. I'm particularly interested in an extension that would intercept them even if e-mailed as I often get e-mailed links to stories in Thunderbird on the aforementioned fanfiction.net.

therube

User avatar
 
Posts: 20061
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted September 21st, 2019, 11:16 am

Link to the Userscripts script?

Might you also need to clear cookies?
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript

slickrcbd
 
Posts: 378
Joined: September 1st, 2010, 1:57 am

Post Posted September 21st, 2019, 6:52 pm

Why would I need to clear cookies?
Although I just got home from having dinner with my mother and together we just cleared the cookies from her cookie jar.
Anyways, here's the link:
https://userscripts-mirror.org/scripts/review/487275

morat
 
Posts: 3445
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 21st, 2019, 10:23 pm

Scripts by LouCypher (test link)
http://userscripts.org/users/12/scripts

Scripts by LouCypher
http://userscripts-mirror.org/users/12/scripts

Code: Select all
document.body.addEventListener("mousedown", function (e) {
 var re = /https?:\/\/userscripts\.org/;
 var targ = e.target || e.srcElement;
 if (targ && targ.href && targ.href.match(re)) {
  targ.href = targ.href.replace(re, "http://userscripts-mirror.org");
 }
});

Left click on the test link on this page redirects correctly using the console to execute the code.

Maybe it is a CSP problem.

You can temporarily turn off CSP to test by disabling the security.csp.enable preference. (restart may be required)

Content Security Policy
http://en.wikipedia.org/wiki/Content_Security_Policy
http://content-security-policy.com/

P.S.

There is a security setting in the Tampermonkey extension.

Add Tampermonkey to the site's content security policy (CSP) if there is one: Yes or No.

Tampermonkey
http://addons.mozilla.org/firefox/addon/683490

slickrcbd
 
Posts: 378
Joined: September 1st, 2010, 1:57 am

Post Posted September 23rd, 2019, 6:41 pm

The redirect userscripts to userscripts-mirror is working, I'm trying to modify it to redirect m.fanfiction.net to www.fanfiction.net, en.m.wikipedia.org to en.wikipedia.org, and others, but I was focusing on those two to start.
If you know anything that might actually do that, I'd appreciate it. however, I'm going to be offline until Sunday after tomorrow night.

therube

User avatar
 
Posts: 20061
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted September 24th, 2019, 9:33 am

Only guessing, but...
Code: Select all
document.body.addEventListener('mousedown', function(e){
    var targ = e.target || e.srcElement;
    if ( targ && targ.href && targ.href.match(/https?:\/\/m.fanfiction.net/) ) {
        targ.href = targ.href.replace(/https?:\/\/m\.fanfiction\.net/, 'http://www.fanfiction.net');
    }
});
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript

morat
 
Posts: 3445
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 24th, 2019, 11:51 am

Anime Naruto (test link)
https://m.fanfiction.net/anime/Naruto/

Anime Naruto
https://www.fanfiction.net/anime/Naruto/

The code by therube works for me. (may not work on sites with strict CSP policies)

slickrcbd
 
Posts: 378
Joined: September 1st, 2010, 1:57 am

Post Posted September 25th, 2019, 12:21 am

I'm not going to be able to test this until next Sunday at the earliest. My uncle has died and I am traveling to Denver from the Chicago suburbs for his memorial. Sorry, I've been doing last-minute packing for all the little things I forgot to prepare, not to mention changing what clothes I'm bringing as I found out plans had been changed and that I'm probably going to need more casual clothes and fewer formal ones (aside from one set for the memorial).

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 6 guests