dividedby / General-URL-Cleaner-Revived

Userscript to clean various URLs and remove tracking elements
https://greasyfork.org/en/scripts/432387-general-url-cleaner-revived
GNU General Public License v3.0
25 stars 8 forks source link

Breaks disq.us redirect. #1

Closed Ghost-BD closed 2 years ago

Ghost-BD commented 2 years ago

Redirect to any other site from disq.us link with this script is not working. Like "https://disq.us/url?url=https://media3.giphy.com/media/l0MYEqEzwMWFCg8rm/giphy.gif:REiNKA71iAPDZrexrL63wFxLIS8&cuid=870217" this link changes to this "https://media3.giphy.com/media/l0MYEqEzwMWFCg8rm/giphy.gif:REiNKA71iAPDZrexrL63wFxLIS8". Extra portion (:REiNKA71iAPDZrexrL63wFxLIS8) at the end of link breaks it. You can check this at any website with disqus.com comment section like "https://wccftech.com/amd-reaffirms-radeon-rx-7000-rdna-3-gpu-ryzen-7000-zen-4-cpu-launch-in-2022-spending-big-money-to-secure-increased-capacity/" where clicking any gif or link other than disq.us doesn't work as expected.

This is a useful script but unfortunately, doesn't work with FireMonkey. Can you make this FireMonkey compatible please? That is a good user script manager.

dividedby commented 2 years ago

Redirect to any other site from disq.us link with this script is not working. Like "https://disq.us/url?url=https://media3.giphy.com/media/l0MYEqEzwMWFCg8rm/giphy.gif:REiNKA71iAPDZrexrL63wFxLIS8&cuid=870217" this link changes to this "https://media3.giphy.com/media/l0MYEqEzwMWFCg8rm/giphy.gif:REiNKA71iAPDZrexrL63wFxLIS8". Extra portion (:REiNKA71iAPDZrexrL63wFxLIS8) at the end of link breaks it. You can check this at any website with disqus.com comment section like "https://wccftech.com/amd-reaffirms-radeon-rx-7000-rdna-3-gpu-ryzen-7000-zen-4-cpu-launch-in-2022-spending-big-money-to-secure-increased-capacity/" where clicking any gif or link other than disq.us doesn't work as expected.

This is a useful script but unfortunately, doesn't work with FireMonkey. Can you make this FireMonkey compatible please? That is a good user script manager.

Is the issue with disq.us still ongoing, I cannot seem to reproduce it. I will have to look into why it isn't working in FireMonkey, I have only used TamperMonkey and ViolentMonkey. I would certainly appreciate any help you can provide in making this script compatible with FireMonkey.

erosman commented 2 years ago

I had a quick glance over the code.

The first thing that I noticed it the use of return which results in parse error as it is not in a function. e.g. line 67, 78, 86, 95, 105, 115, 127, 140, 156, 161, 170, 175, 180, 185

Uncaught SyntaxError: return not in function

GM|VM|TM wrap userscripts in an anonymous function in order to sandbox it and that is the reason userscript doesn't cause a parse error.

FireMonkey injects the scripts as they are. In order to use return and make it work with all userscript manager, you can wrap the code in an anonymous function e.g.

// ==UserScript==
// @run-at      document-start
// @name        General URL Cleaner Revived
// @name:ja     General URL Cleaner Revived
// @namespace   https://greasyfork.org/en/users/594496-divided-by
// @description Cleans URL's from various popular sites.
// @description:ja Cleans URL's from various popular sites.
// @include     https://www.newegg.com/*
// @include     https://www.newegg.ca/*
// @include     https://www.bing.com/*
// @include     https://www.youtube.com/*
// @include     https://www.imdb.com/*
// @include     https://www.facebook.com/*
// @include     https://disqus.com/embed/comments/*
// @include     https://www.target.com/*
// @include     /^https://[a-z]+\.amazon(\.com?)?\.[a-z]{2,3}/.*$/
// @include     /^https?://[a-z]+\.google(\.com?)?\.[a-z]{2,3}/.*$/
// @include     /^https://[a-z.]+\.ebay(desc)?(\.com?)?\.[a-z]{2,3}/.*$/
// @include     /^https://[a-z0-9.]*twitter.com/.*$/
// @include     /^https?://(www\.)?staticice\.com\.au/.*$/
// @include     https://app.getpocket.com/*
// @exclude     https://apis.google.com/*
// @exclude     https://accounts.google.com/*
// @exclude     https://support.google.com/*
// @exclude     https://www.google.com/recaptcha/*
// @exclude     https://hangouts.google.com/webchat/*
// @exclude     https://gsuite.google.com/*
// @exclude     https://calendar.google.com/*
// @exclude     https://docs.google.com/spreadsheets/*
// @exclude     https://takeout.google.com/*
// @version     4.0.1
// @license     GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dividedbyerror@gmail.com&item_name=Greasy+Fork+Donation
// @contributionAmount $1
// ==/UserScript==

(() => {

// the code here

})();

The following also causes a parse error as href is not defined. https://github.com/dividedby/General-URL-Cleaner-Revived/blob/e13303f99f21a5a53359a18d75eeefe7c1207412/URLClean.js#L327

Ghost-BD commented 2 years ago

The issue is still there. Just go to this page and check any link in comment section to reproduce it General URL Cleaner Revived with VM - link breakage .

dividedby commented 2 years ago

The issue is still there. Just go to this page and check any link in comment section to reproduce it General URL Cleaner Revived with VM - link breakage .

Hey there, been busy with my newborn but I pushed what I hope is a fix for the disq.us link issue. I will do what I can to look into the compatibility with FireMonkey. Apologies for such sporadic updates.

Ghost-BD commented 2 years ago

Fixed but no more clean URL for disqus. Take your time as you need and congratulation by the way. Thanks again.