PageSourceSearch

https://grupopromove.com.br/public/js/instastory.js

js grupopromove.com.br collected 2026-10-04 14:24:29 UTC 5,081 bytes, 149 lines download raw bytes

1
2
3(function($) {
4    $.fn.instastory = function(userSettings) {
5        let $container = this;
6        let searchUrl = "";
7        let settings = $.extend({
8            get         : "",
9            type        : "",
10            imageSize   : 240,
11            limit       : 4,
12            link        : true,
13            template    : ""
14        }, userSettings);
15        
16        if(typeof userSettings == "string") {
17            settings.get = userSettings;
18        }
19
20        const determineType = function(searchString) {
21            if(searchString.indexOf("@") > -1) {
22                settings.type = "user";
23                settings.get = searchString.substring(searchString.indexOf('@') + 1);
24            } else if(searchString.indexOf("#") > -1) {
25                settings.type = "hashtag";
26                settings.get = searchString.substring(searchString.indexOf('#') + 1);
27            } else {
28                settings.type = "hashtag";
29                settings.get = searchString;
30            }
31        }
32
33        const determineUrl = function(searchType) {
34            if(searchType == "user") {
35                searchUrl = "https://www.instagram.com/" + settings.get + "/?__a=1"
36            } else {
37                searchUrl = "https://www.instagram.com/explore/tags/" + settings.get + "/?__a=1";
38            }
39        }
40
41        const getImageSize = function(post) {
42            const wantedImageSize = settings.imageSize;
43
44            if(typeof wantedImageSize == "number") {
45                switch(wantedImageSize) {
46                    case 150:
47                        return post.thumbnail_resources[0].src;
48                    case 240:
49                        return post.thumbnail_resources[1].src;
50                    case 320:
51                        return post.thumbnail_resources[2].src;
52                    case 480:
53                        return post.thumbnail_resources[3].src;
54                    case 640:
55                        return post.thumbnail_resources[4].src;
56                    default:
57                        return post.thumbnail_resources[0].src;
58                }
59            } else if(wantedImageSize == "raw") {
60                return post.display_url;
61            } else {
62                return post.thumbnail_resources[0].src;
63            }
64            
65        };
66
67        const buildTemplate = function(post) {
68            String.prototype.allReplace = function(obj) {
69                let retStr = this;
70                for (let x in obj) {
71                    retStr = retStr.replace(new RegExp(x, "g"), obj[x]);
72                }
73                return retStr;
74            };
75
76            let templateCodes = {
77                "{{accessibility_caption}}" : post.accessibility_caption,
78                "{{caption}}": post.edge_media_to_caption.edges[0],
79                "{{comments}}": post.edge_media_to_comment.count,
80                "{{image}}": getImageSize(post),
81                "{{likes}}": post.edge_liked_by.count,
82                "{{link}}": "https://www.instagram.com/p/"+ post.shortcode,
83            }
84
85            let template = settings.template.allReplace(templateCodes);
86
87            return template;
88        }
89
90        const generateHtml = function(ajaxResult) {
91            let html = "";
92            let postsObject = {};
93            
94            switch (settings.type) {
95                case "user":
96                    postsObject = ajaxResult.edge_owner_to_timeline_media;
97                    break;
98            
99                default:
100                    postsObject = ajaxResult.edge_hashtag_to_media;
101                    break;
102            }
103
104            let posts = postsObject.edges;
105
106
107            for(var i = 0; i < settings.limit; i++) {
108
109                if(posts[i] !== undefined) {
110                    let post = posts[i].node;
111                    let tempHtml = "";
112
113                    if(settings.template != "") {
114                        tempHtml = buildTemplate(post);
115                    } else {
116                        tempHtml = "<img src='" + getImageSize(post) + "' alt='" + post.accessibility_caption + "'>"
117                    
118                        if(settings.link) {
119                            tempHtml = "<a href='https://www.instagram.com/p/"+ post.shortcode +"'>" + tempHtml + "</a>";
120                        }
121                    }
122
123                    html += tempHtml;
124                }   
125            }
126
127            return html;
128        };
129
130        determineType(settings.get);
131        determineUrl(settings.type);
132
133        $.ajax({
134            url: searchUrl,
135            success: function(data) {
136                $container.html(generateHtml(data.graphql[settings.type]));
137            }
138        }).fail(function(data) {
139            switch(data.status) {
140                case 404:
141                    console.warn("The " + settings.type + " do not exsists, please try another one");
142                break;
143                default:
144                    console.warn('An unknow error happend');
145                break;
146            }
147        });
148    }
149})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.