General URL Cleaner

Cleans URL's from various popular sites.

< Σχολιασμός για τον κώδικα General URL Cleaner

Ερώτηση/σχόλιο

§
Δημοσιεύτηκε: 04/08/2015

On Youtube, page links with redirect (

image Opera 31.0.1889.98 beta/Tampermonkey

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 12/08/2015

I've never actually seen a youtube redirect link like that before.

I think should work with this regex:

var youtubeRedirectLink = new RegExp(/^https?:\/\/www.youtube.com\/redirect\?q\=/);

And this case in the main cleaning function:

        case youtubeRedirectLink.test(oldurl):
            decodeURIComponent(oldurl.replace(youtubeRedirectLink,'').replace(/\&redir_token\=.*/,''));
            break;
§
Δημοσιεύτηκε: 17/08/2015

And this case in the main cleaning function:

It did not help me ( image

But the script YouTube Link Cleaner works, probably necessary to delete class="yt-uix-redirect-link" image

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 22/08/2015
Επεξεργάστηκε: 22/08/2015

I figured out why that script works and mine doesn't: There seems to be a script on youtube that keeps changing the links to a redirect link. And the script you linked keeps running the cleaning function every second, using window.setInterval(ChangeLinks, 1000);

I'd rather try to use something like MutationObserver to detect when the links are modified, and modify them back, so that it doesn't eat CPU time running the function over and over again if it doesn't have to.

edit

Scratch that, I noticed that the links don't actually change until you click on them. And all I need to do is remove the class to prevent them from doing so. I just added this and it seems to work:

else if(links[i].class="yt-uix-redirect-link") links[i].removeAttribute("class");

And it doesn't have to keep observing page changes or run the function again.

§
Δημοσιεύτηκε: 23/08/2015
Επεξεργάστηκε: 23/08/2015

cratch that, I noticed that the links don't actually change until you click on them. And all I need to do is remove the class to prevent them from doing so. I just added this and it seems to work:

No ( Redirects remain in the current version. In previous (2.0.3.2 w/o youtube player control) - no redirects.

ps. But in FF v40.0.2 works now, unlike Opera v32,33 or Chrome v44

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 23/08/2015
Επεξεργάστηκε: 23/08/2015

OK, it looks like:

if (links[i].className.contains("yt-uix-redirect-link")

Only works in Firefox, while:

if (links[i].class="yt-uix-redirect-link")

Seems to work in Firefox and Opera.

In the version where youtube HTML5 player controls disappeared, it was just removing the class property from all page links.

§
Δημοσιεύτηκε: 24/08/2015

In the version where youtube HTML5 player controls disappeared, it was just removing the class property from all page links.

Again youtube play controls removed in Opera/Chrome/FF \

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 24/08/2015
Επεξεργάστηκε: 24/08/2015

OK, I'm not gonna lie, this has actually been kinda pissing me off. But I think I've finally got it:

if (/ytp-button$/.test(links[i].className) == false) links[i].removeAttribute('class');

I tested that in Opera and Firefox.

I still don't know why it was breaking the HTML5 player buttons with

if (links[i].class="yt-uix-redirect-link")

given that they don't actually have that class name.

§
Δημοσιεύτηκε: 24/08/2015

But I think I've finally got it:

Yes, with Youtube all ok now, thanks. But all links to amazon in google search result now look so (checked on Opera & FF): image

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 24/08/2015

I remember fixing that one on Amazon's own website, but looks like I forgot to do it for google and bing.

§
Δημοσιεύτηκε: 26/08/2015

New version - on Opera/Chrome again youtube redirects \

KnowbodyΔημιουργός
§
Δημοσιεύτηκε: 26/08/2015
Επεξεργάστηκε: 26/08/2015

I forgot to actually put in the youtubeClasses regex I made on greasyfork. I'm annoyed at myself for that.

Δημοσίευση απάντησης

Συνδεθείτε για να δημοσιεύσετε μια απάντηση.