-
-
Save gmammolo/8528e393bc91c54717f21620b6979431 to your computer and use it in GitHub Desktop.
Custom Rule zhanghai/Untracker script: Instagram share reels untracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This script is a custom script for the Android app [Untracker](https://github.com/zhanghai/Untracker). | |
When sharing a reel from the Instagram app on Android, you get a link in the format `https://www.instagram.com/share/reel/...`. | |
This link contains a redirect to a direct link to the reel, but with a hidden tracker. | |
This script removes the tracker and returns the direct link to the reel. | |
*/ | |
if ($.matches(url, 'www.instagram.com', '/share/reel/[^/]+/?')) { | |
let counter = 10; | |
while (counter > 0) { | |
response = $.fetch(url, { redirect: 'follow' }); | |
for ([name, value] of response.headers) { | |
if (name.toLowerCase() === 'location') { | |
url = value; | |
continue; | |
} | |
} | |
if($.matches(url, 'www.instagram.com', '/reel/[^/]+/?')) { | |
break; | |
} | |
counter--; | |
} | |
url = url.replace(/\?.*$/, ''); | |
return url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment