Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bookmarklets.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{
"name": "unskim",
"file": "unskim.bookmarklet",
"version": "2.0.2"
"version": "2.1.0"
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bookmarklets.json bumps unskim to 2.1.0, but README.md still references unskim v2.0.2 (including the embedded bookmarklet/setup links). If the README is expected to reflect current bookmarklet versions/code, re-run the README generation step (e.g., npm run build:readme / npm run deploy) and include the resulting README updates in this PR.

Suggested change
"version": "2.1.0"
"version": "2.0.2"

Copilot uses AI. Check for mistakes.
},
{
"name": "x-man",
Expand Down
2 changes: 1 addition & 1 deletion dist/unskim.bookmarklet
Original file line number Diff line number Diff line change
@@ -1 +1 @@
javascript:'use%20strict'%3B(()=%3E%7Blet%20e=new%20URL(document.location.href)%3Bif('safari-resource:%2FErrorPage.html'===e.href)%7Bconst%20t=document.querySelector('p.error-message')%3F.textContent%3F.match(%2FSafari%20can't%20open%20the%20page%20%22(https%3F:%5B%5E%22%5D%2B)%22%2F)%3F.%5B1%5D%3Bt%26%26(e=new%20URL(t))%7Dif(13%3Ee.search.length)return%3Bconst%20t=new%20URLSearchParams(e.search)%2Cr=%5B'url'%2C'destination'%2C'redirect'%2C'target'%2C'goto'%2C'u'%2C'dest'%2C'link'%2C'out'%5D.filter(e=%3Et.has(e)).map(e=%3E%7Bconst%20r=t.get(e)%3Breturn%20r%3FdecodeURIComponent(r):''%7D).find(e=%3Ee.match(%2F%5Ehttps%3F:%2F))%3Br%26%26window.location.replace(new%20URL(r))%7D)()%3Bvoid'2.0.2'
javascript:'use%20strict'%3B(()=%3E%7Blet%20e=new%20URL(document.location.href)%3Bif('safari-resource:%2FErrorPage.html'===e.href)%7Bconst%20t=document.querySelector('p.error-message')%3F.textContent%3F.match(%2FSafari%20can't%20open%20the%20page%20%22(https%3F:%5B%5E%22%5D%2B)%22%2F)%3F.%5B1%5D%3Bt%26%26(e=new%20URL(t))%7Dif(13%3Ee.search.length)return%3Bconst%20t=new%20URLSearchParams(e.search)%2Cr=%5B'url'%2C'destination'%2C'redirect'%2C'target'%2C'goto'%2C'u'%2C'dest'%2C'link'%2C'out'%5D.filter(e=%3Et.has(e)).map(e=%3E%7Bconst%20r=t.get(e)%3Breturn%20r%3FdecodeURIComponent(r):''%7D).find(e=%3Ee.match(%2F%5Ehttps%3F:%2F))%3Bif(r)%7Bconst%20e=new%20URL(r)%3Bif(e.searchParams.size%3E0)%7Bconst%20t=new%20URLSearchParams(e.search)%3Bfor(const%20e%20of%5B...t.keys()%5D)%7Bconst%20r=e.toLowerCase()%3B(r.startsWith('utm%5F')%7C%7Cr.startsWith('fb%5F')%7C%7C%5B'fbclid'%2C'gclid'%2C'msclkid'%2C'ref'%2C'referrer'%2C'ttclid'%2C'twclid'%5D.includes(r))%26%26t.delete(e)%7De.search=t.toString()%7Dwindow.location.replace(e)%7D%7D)()%3Bvoid'2.1.0'
16 changes: 14 additions & 2 deletions src/unskim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@
})
.find((url: string) => url.match(/^https?:/));

// navigate to new URL if found
// navigate to new URL if found, after stripping common tracking params
if (urlCandidate) {
window.location.replace(new URL(urlCandidate));
const targetUrl: URL = new URL(urlCandidate);
if (targetUrl.searchParams.size > 0) {
const targetParams: URLSearchParams = new URLSearchParams(targetUrl.search);
for (const key of [...targetParams.keys()]) {
const k: string = key.toLowerCase();
if (k.startsWith('utm_') || k.startsWith('fb_') ||
['fbclid', 'gclid', 'msclkid', 'ref', 'referrer', 'ttclid', 'twclid'].includes(k)) {
targetParams.delete(key);
}
}
targetUrl.search = targetParams.toString();
Comment on lines +42 to +50
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetUrl.search is re-serialized for any URL that has any query params, even if no tracking params are removed. Reconstructing via URLSearchParams(...).toString() can normalize encoding (e.g., %20+) and potentially change URLs unnecessarily. Consider mutating targetUrl.searchParams directly and only changing the URL when a matching tracking param is actually deleted.

Suggested change
const targetParams: URLSearchParams = new URLSearchParams(targetUrl.search);
for (const key of [...targetParams.keys()]) {
const k: string = key.toLowerCase();
if (k.startsWith('utm_') || k.startsWith('fb_') ||
['fbclid', 'gclid', 'msclkid', 'ref', 'referrer', 'ttclid', 'twclid'].includes(k)) {
targetParams.delete(key);
}
}
targetUrl.search = targetParams.toString();
let removedTrackingParam = false;
for (const key of [...targetUrl.searchParams.keys()]) {
const k: string = key.toLowerCase();
if (k.startsWith('utm_') || k.startsWith('fb_') ||
['fbclid', 'gclid', 'msclkid', 'ref', 'referrer', 'ttclid', 'twclid'].includes(k)) {
targetUrl.searchParams.delete(key);
removedTrackingParam = true;
}
}
if (!removedTrackingParam) {
// Preserve the original query-string serialization when nothing was removed.
}

Copilot uses AI. Check for mistakes.
}
window.location.replace(targetUrl);
}

})();
Loading