Ditto icon indicating copy to clipboard operation
Ditto copied to clipboard

A keyboard shortcut that strips all trackers,references,affiliate etc.. from URLs presently in the clipboard ?

Open shodanx2 opened this issue 3 years ago • 3 comments

Here for example I have these URL that happen to be in my clipboard

https://addons.mozilla.org/en-CA/firefox/addon/darkreader/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search https://addons.mozilla.org/en-CA/firefox/addon/dark-mode-webextension/ https://addons.mozilla.org/en-CA/firefox/addon/dark-background-light-text/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search https://addons.mozilla.org/en-CA/firefox/addon/dark-mode-by-albert-inc/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search

In this case, everything after the ? is superfluous tracking

I would like to hit a key and my clipboard becomes

https://addons.mozilla.org/en-CA/firefox/addon/darkreader/ https://addons.mozilla.org/en-CA/firefox/addon/dark-mode-webextension/ https://addons.mozilla.org/en-CA/firefox/addon/dark-background-light-text/ https://addons.mozilla.org/en-CA/firefox/addon/dark-mode-by-albert-inc/

shodanx2 avatar Sep 10 '22 23:09 shodanx2

You can go into options - general - advanced - paste scripts and create a new script. Give it a name and add the following to the script. This will replace everything including ? and after with an empty string. You can then assign a keyboard shortcut in options - quick paste keyboard, this would only be active when Ditto is in focus

`clip.AsciiTextReplaceRegex("\?.*", "");

return false`

image

image

image

sabrogden avatar Sep 15 '22 03:09 sabrogden

I called it "Strip trackers and affiliates"

image

~~And it works !!~~

turned this mess

https://www.aliexpress.com/item/3256803658093626.html?spm=a2g0o.productlist.0.0.603b6950Ro7urU&algo_pvid=51272dd1-342e-4030-8418-9fb96aa7bef1&algo_exp_id=51272dd1-342e-4030-8418-9fb96aa7bef1-15&pdp_ext_f=%7B%22sku_id%22%3A%2212000028855121227%22%7D&pdp_npi=2%40dis%21USD%2116.35%218.99%21%21%21%21%21%40210318b816632182137706852e4b51%2112000028855121227%21sea&curPageLogUid=6vCqkz334fsC https://www.aliexpress.com/item/3256802263338614.html?spm=a2g0o.productlist.0.0.603b6950Ro7urU&algo_pvid=51272dd1-342e-4030-8418-9fb96aa7bef1&algo_exp_id=51272dd1-342e-4030-8418-9fb96aa7bef1-18&pdp_ext_f=%7B%22sku_id%22%3A%2212000023434028096%22%7D&pdp_npi=2%40dis%21USD%211.15%210.69%21%21%21%21%21%40210318b816632182137706852e4b51%2112000023434028096%21sea&curPageLogUid=Ko4TJ0drRDvV https://www.aliexpress.com/item/3256803464994882.html?spm=a2g0o.productlist.0.0.7ad247d6ZFL3vr&algo_pvid=512c935d-d320-4292-aaef-a1b4869c1b64&algo_exp_id=512c935d-d320-4292-aaef-a1b4869c1b64-42&pdp_ext_f=%7B%22sku_id%22%3A%2212000027107739591%22%7D&pdp_npi=2%40dis%21USD%2129.0%2129.0%21%21%21%21%21%40210318b816632182274333285e4b67%2112000027107739591%21sea&curPageLogUid=QlMynbTdvoOf https://www.aliexpress.com/item/2251832837583131.html?spm=a2g0o.productlist.0.0.771c5ddcrUna5T&algo_pvid=a453babf-79f8-4bc8-a32e-8c2a34cc8431&algo_exp_id=a453babf-79f8-4bc8-a32e-8c2a34cc8431-5&pdp_ext_f=%7B%22sku_id%22%3A%2267239149477%22%7D&pdp_npi=2%40dis%21USD%2161.5%2157.81%21%21%21%21%21%402103143616632182907613093e99a3%2167239149477%21sea&curPageLogUid=GQArOvLnoJm4

into

https://www.aliexpress.com/item/3256803658093626.html?spm=a2g0o.productlist.0.0.603b6950Ro7urU&algo_pvid=51272dd1-342e-4030-8418-9fb96aa7bef1&algo_exp_id=51272dd1-342e-4030-8418-9fb96aa7bef1-15&pdp_ext_f=%7B%22sku_id%22%3A%2212000028855121227%22%7D&pdp_npi=2%40dis%21USD%2116.35%218.99%21%21%21%21%21%40210318b816632182137706852e4b51%2112000028855121227%21sea&curPageLogUid=6vCqkz334fsC https://www.aliexpress.com/item/3256802263338614.html?spm=a2g0o.productlist.0.0.603b6950Ro7urU&algo_pvid=51272dd1-342e-4030-8418-9fb96aa7bef1&algo_exp_id=51272dd1-342e-4030-8418-9fb96aa7bef1-18&pdp_ext_f=%7B%22sku_id%22%3A%2212000023434028096%22%7D&pdp_npi=2%40dis%21USD%211.15%210.69%21%21%21%21%21%40210318b816632182137706852e4b51%2112000023434028096%21sea&curPageLogUid=Ko4TJ0drRDvV https://www.aliexpress.com/item/3256803464994882.html?spm=a2g0o.productlist.0.0.7ad247d6ZFL3vr&algo_pvid=512c935d-d320-4292-aaef-a1b4869c1b64&algo_exp_id=512c935d-d320-4292-aaef-a1b4869c1b64-42&pdp_ext_f=%7B%22sku_id%22%3A%2212000027107739591%22%7D&pdp_npi=2%40dis%21USD%2129.0%2129.0%21%21%21%21%21%40210318b816632182274333285e4b67%2112000027107739591%21sea&curPageLogUid=QlMynbTdvoOf https://www.aliexpress.com/item/2251832837583131.html?spm=a2g0o.productlist.0.0.771c5ddcrUna5T&algo_pvid=a453babf-79f8-4bc8-a32e-8c2a34cc8431&algo_exp_id=a453babf-79f8-4bc8-a32e-8c2a34cc8431-5&pdp_ext_f=%7B%22sku_id%22%3A%2267239149477%22%7D&pdp_npi=2%40dis%21USD%2161.5%2157.81%21%21%21%21%21%402103143616632182907613093e99a3%2167239149477%21sea&curPageLogUid=GQArOvLnoJm4

Oh wait, it doesn't work actually

Investigating

image

I just tried many different changes, trying to find that elusive "carriage return" I even retyped the whole thing in notepad and pasted it. I don't understand what's wrong here

shodanx2 avatar Sep 15 '22 05:09 shodanx2

You need 2 slashes before the ?. When you paste 2 slashes in this window it only shows 1.

`clip.AsciiTextReplaceRegex("\\?.*", "");

return false`

sabrogden avatar Sep 15 '22 20:09 sabrogden

Thanks ! Just had another go at this, but I'm doing something wrong

image

Tried various iterations

image

still no go

image

I don't know what I'm doing wrong

shodanx2 avatar Nov 08 '22 06:11 shodanx2

@shodanx2

You are adding unnecessary ` characters. It seems to me that the error message gives you a clue about this. Remove the offensive characters and I think the script will work fine.

I have a similar script and it works perfectly fine:

clip.AsciiTextReplaceRegex("utm.*", "");
return false;

Best regards, Claudio Salvio

claudio-salvio avatar Nov 11 '22 11:11 claudio-salvio

@shodanx2

I test your script with my previous recommendation and it didn't work either.

To make it work I had to rewrite it as:

clip.AsciiTextReplaceRegex("[?].*", "" );

return false

Best regards, Claudio Salvio

claudio-salvio avatar Nov 11 '22 15:11 claudio-salvio

Thank you, this works !

Now to re-iterate for anyone following at home

Step 1 , right click Ditto system tray icon and click options

image

Step 2

In the general tab, click advanced

image

Step 3

Click on paste scripts

image

Step 4

Click Add,

Then fill in Name

Remove URL Trackers

And paste in the code

clip.AsciiTextReplaceRegex("[?].*", "" );

return false

then click Ok - Ok - Ok

Now to use this paste script

Click your destination click box

Press CTRL + ~ on your keyboard to popup Ditto screen

Right click on what you want to paste

And click Remove URL Trackers under Special paste

image

Nice ! It works !

shodanx2 avatar Nov 14 '22 02:11 shodanx2

It was clear once you posted your first screenshot of your filter that the syntax wasn't right, since you're carrying markdown quote syntax into the the chaiscript script window.

garoto avatar Nov 14 '22 02:11 garoto

Thank you for this useful tool, I am already putting it into practice

If you would like another puzzle like this I have created another request for a somewhat similar filter

Suggestion : On paste script that removes double entries in a multi-line paste ?

shodanx2 avatar Nov 14 '22 07:11 shodanx2