Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the DDLInstagram feature to removeTrackingURL (an alternative Instagram that converts to embed text and images or videos). #5

Open
ryukora opened this issue Jun 26, 2023 · 3 comments

Comments

@ryukora
Copy link

ryukora commented Jun 26, 2023

Can you add ddinstagram.com (replacing Instagram alternative links for conversion and embedding with text and video) to removeTrackingURL? I'd like to if you can do it.

These are examples of IG reels and posts:

www.instagram.com/reel/[videolink]/?igshid=[trackinglink]A==]
www.instagram.com/p/[postsimagelink]/?utm_source=ig_web_copy_link&igshid=[trackinglink]==

You can remove those tracking links if you don't need them.

Thanks! 🙏

@wotanut
Copy link
Owner

wotanut commented Jun 27, 2023

Hi there, sorry for the slow response.

This is definitely something I can do and I’ll put it in my list of things to do.

@ryukora
Copy link
Author

ryukora commented Jun 28, 2023

Hi there, sorry for the slow response.

This is definitely something I can do and I’ll put it in my list of things to do.

Okay, good luck with the project! I hope you can do it as well as you can.

@ryukora
Copy link
Author

ryukora commented Jun 29, 2023

Hi there, sorry for the slow response.

This is definitely something I can do and I’ll put it in my list of things to do.

Maybe the REGEX of Instagram reels and posts should work like this.

            this.defaultSettings.instagram_reels = true;
            this.defaultSettings.instagram_posts = true;
            this.defaultSettings.DDInstagram_reels = false;
            this.defaultSettings.DDInstagram_posts = false

    const REGEX = {
		"instagram_reels": /((?:https|http)\:\/\/(?:www\.)?instagram\.com\/(?:reel|reels)\/[a-zA-Z0-9-_]+\/?(?:\?\S+)?)\S*/g,
		"instagram_posts": /((?:https|http)\:\/\/(?:www\.)?instagram\.com\/p\/[a-zA-Z0-9-_]+\/?(?:\?\S+)?)\S*/g,

            // instagram_reels

            // example of a instagram reels link 
            // https://www.instagram.com/reels/xxxxxxx/


            if (this.settings.instagram_reels) {
                if (msgcontent.includes("https://instagram.com/reel/")) {

                    // if it includes the instagram reels url then it'll flow down here and appropriately remove the trackers and update the url.
                    // note: for those of you who /care/ so much about speed you will get a very slight performance increase if you use DDInstagram.
                    msgcontent = this.sanitizeUrls(msgcontent, REGEX.instagram_reels);

                    if (this.settings.DDInstagram_reels) {
                        msgcontent = msgcontent.replace("https://instagram.com/reel/", "https://ddinstagram.com/reel/");
                    }
                    if (this.settings.showToasts && isFromSomeoneEsle == false) {
                        Toasts.success("Succesfully removed tracker from instagram reels link!");
                    }
                }
            }
			
            // instagram_posts

            // example of a instagram posts link 
            // https://www.instagram.com/p/xxxxxxxx/


            if (this.settings.instagram_posts) {
                if (msgcontent.includes("https://instagram.com/p/")) {

                    // if it includes the instagram posts url then it'll flow down here and appropriately remove the trackers and update the url.
                    // note: for those of you who /care/ so much about speed you will get a very slight performance increase if you use DDInstagram.
                    msgcontent = this.sanitizeUrls(msgcontent, REGEX.instagram_posts);

                    if (this.settings.DDInstagram_posts) {
                        msgcontent = msgcontent.replace("https://instagram.com/p/", "https://ddinstagram.com/p/");
                    }
                    if (this.settings.showToasts && isFromSomeoneEsle == false) {
                        Toasts.success("Succesfully removed tracker from instagram posts link!");
                    }
                }
            }

                new Settings.Switch("Instagram Reels", "Remove instagram reels tracking URL", this.settings.instagram_reels, (i) => { this.settings.instagram_reels = i; }),
                new Settings.Switch("Instagram Posts", "Remove instagram posts tracking URL", this.settings.instagram_posts, (i) => { this.settings.instagram_posts = i; })

                    new Settings.Switch("DDInstagram Reels", "Automatically convert instagram reels links to DDInstagram Reels links", this.settings.instagram_reels, (i) => { this.settings.instagram_reels = i; }),
                    new Settings.Switch("DDInstagram Posts", "Automatically convert instagram posts links to DDInstagram Posts links", this.settings.instagram_posts, (i) => { this.settings.instagram_posts = i; })

You can consider fixing what I just made, or you can make it yourself.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants