PageSourceSearch

https://sellersprite.ai/assets-v2/js/module-publick-IPS-language.js?v202609241633

js sellersprite.ai collected 2026-09-24 13:05:01 UTC 18,352 bytes, 401 lines download raw bytes

1/*
2 * @Author: your name
3 * @Date: 2021-05-14 14:02:25
4 * @LastEditTime: 2021-07-16 17:02:00
5 * @LastEditors: Please set LastEditors
6 * @Description: In User Settings Edit
7 * @FilePath: \amazon-backend\rank-monitor\src\main\webapp\assets-v2\js\module-publick-IPS-language.js
8 */
9$(function () {
10    var Fn = {
11        node: {
12            $body: $("body"),
13            text: {},
14            handler: null,
15            $globalBindWechatModal: $("#global-bind-wechat-modal"),
16            current_clientId: null,
17            // 插件相关信息,为空时表示未安装插件,值示例:{id:'xxx', version:'3.0.0'}
18            // v3.0.3起才开始赋值
19            // v3.0.7起,增加属性 source S=store(在线安装) L=local(本地安装) 适用于chrome内核浏览器
20            extension: null,
21        },
22        init: function (lang, module) {
23            let that = this;
24            that.initCustomEventListener();
25            //   全局免费用户绑定二维码
26            that.node.$body.on("click", ".globalBindWechatBtn", function () {
27                that.showGlobalBindWechat($(this));
28                return;
29            });
30            that.node.$globalBindWechatModal.on("click", ".qr-code.islose", function () {
31                that.getQrCode();
32                return;
33            });
34            that.node.$globalBindWechatModal.on("show.bs.modal", function (event) {
35                that.getQrCode();
36            });
37            that.node.$globalBindWechatModal.on('hide.bs.modal', function (event) {
38                that.node.handler && clearInterval(that.node.handler);
39            });
40            // 判断是否含有亚马逊url 如果有则截取asin,如果有空格和逗号号则不变
41            that.node.$body.on("input",'.searchGetLinkAsin',function(){
42                that.detectionGetLinkAsin($(this));
43                return
44            });
45            if(that.newBeginnerLocalStorage(false, 'RESTRICTED_fREE_PROMOTION') != 'N' && $(".restricted-free-promotion-modal").length){
46                $(".restricted-free-promotion-modal").addClass("isopen");
47            }
48            // 限时免费推广
49            that.node.$body.on("click",".restricted-free-promotion-modal .switch-restricted",function(){
50                let itemSwitch = $(this).is(".show-restricted");
51                $(".restricted-free-promotion-modal").removeClass("isopen").addClass(itemSwitch?"isopen":"");
52                that.newBeginnerLocalStorage(!itemSwitch, 'RESTRICTED_fREE_PROMOTION',);
53                window.localStorage.setItem('RESTRICTED_fREE_PROMOTION', itemSwitch?'Y':'N');
54                return;
55            });
56        },
57        AddTopIPSDynamically: function () {
58            let that = this;
59            if ($("#add-topIPS-dynamically").length) {
60                return;
61            }
62            // 1小时请求一次
63            let local_cached_hour_key = 'TOP_SCROLL_HIT_HOUR_TIME',
64                cached = localStorage.getItem(local_cached_hour_key);
65            try{if (cached != null && new Date(parseInt(cached)).getTime() > new Date().getTime() - 3600000) return false;}catch (e) {}
66
67            let TopIPShtml = '<div class="add-topIPS-dynamically" id="add-topIPS-dynamically" style="display:block"><div class="d-flex topIPS-dynamically-flex" >'
68            TopIPShtml += '<div class="topIPS-dynamically-content flex-customer-1"></div>'
69            TopIPShtml += '<i class="iconfont icon-shanchu ml-4" style="margin:0"></i>'
70            TopIPShtml += '</div></div>'
71            $.ajax({
72                type: 'get',
73                url: '/v2/top-scroll/one',
74                contentType: "application/json;charset=UTF-8",
75                data: {},
76                dataType: 'json',
77                async: false,
78                success: function (result) {
79                    if (result && result.code === "OK") localStorage.setItem(local_cached_hour_key, new Date().getTime());
80
81                    if (result && result.code === "OK" && result.data) {
82                        // 删除标识符,每次都请求
83                        localStorage.removeItem(local_cached_hour_key);
84
85                        $("body").prepend(TopIPShtml);
86                        if (result.backgroundImage) {
87                            const img = new Image();
88                            img.onload = function() {
89                                $("#add-topIPS-dynamically").css({
90                                    "background-image": "url(" + result.backgroundImage 
90+ ")"
91                                })
92                            };
93                            img.src = result.backgroundImage;
94                        }
95                        $("#add-topIPS-dynamically").attr("data-url", result.url).attr("data-tipsId", result.tipsId).find(".topIPS-dynamically-content").html(result.content).end()
96                            .fadeIn();
97                        $("#add-topIPS-dynamically").on("click", ".icon-shanchu", function (event) {
98                            that.readTipIPSDynamically($(this));
99                            event.stopPropagation();
100                        });
101                        $("#add-topIPS-dynamically").on("click", ".topIPS-dynamically-flex", function () {
102                            that.readTipIPSDynamically($(this), 'link');
103                        });
104                    } else {
105                        $("#add-topIPS-dynamically").remove();
106                    }
107
108                }
109            })
110        },
111
112        readTipIPSDynamically: function ($this, isUrl) {
113            let tipsId = $this.parents(".add-topIPS-dynamically").attr("data-tipsId"),
114                isLinkUrl = $this.parents(".add-topIPS-dynamically").attr("data-url");
115            isUrl ? window.open(isLinkUrl) : null;
116            $this.parents(".add-topIPS-dynamically").remove();
117            if (!tipsId) {
118                return
119            }
120            $.ajax({
121                type: 'get',
122                url: '/v2/top-scroll/read?tipsId=' + tipsId,
123                contentType: "application/json;charset=UTF-8",
124                data: {},
125                dataType: 'json',
126                async: false,
127                success: function (result) {
128                    if (result && result.code == "OK") {} else {}
129                }
130            })
131        },
132        //   全局免费用户绑定微信
133        showGlobalBindWechat: function ($this) {
134            let that = this;
135            that.node.current_clientId = $this.attr("data-current_clientId");
136            that.node.current_clientId ? that.node.$globalBindWechatModal.modal("show") : null;
137        },
138        showGlobalBindWechatInit:function(ele){
139            this.showGlobalBindWechat($(ele));
140        },
141        // 绑定微信
142        getQrCode: function () {
143            let that = this;
144            that.node.handler && clearInterval(that.node.handler);
145            that.node.$globalBindWechatModal.find('.qr-tips').text('').end().find(".qr-code").removeClass("islose");
146            $.ajax({
147                type: "get",
148                url: "/v2/wx/getQrCodeTicket/" + that.node.current_clientId + "?fresh=" + true + "&bind=" + false,
149                dataType: "json",
150                success: function (data) {
151                    if (data.code === 200) {
152                        var url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + data.ticket;
153                        that.node.$globalBindWechatModal.find('.qr-code').attr('src', url);
154                        setTimeout(function () {
155                            that.node.$globalBindWechatModal.find(".qr-code").addClass("islose").end().find('.qr-tips').addClass('text-danger').text('二维码过期,点击二维码刷新');
156                        }, 60000);
157                        that.getScanState(data);
158                    }
159                }
160            });
161        },
162        getScanState: function (data) {
163            let that = this,
164                k = 40;
165            that.node.handler = setInterval(function () {
166                if (k < 0) {
167                    that.node.handler && clearInterval(that.node.handler);
168                    return;
169                }
170                k--;
171                $.ajax({
172                    type: "get",
173                    url: "/v2/wx/getQrState?ticket=" + data.ticket,
174                    dataType: "json",
175                    success: function (state) {
176                        clearInterval(that.node.handler);
177                        var code = state.code;
178                        if (code === 1003) {
179                            // 微信绑定成功后如果之前有提醒咯则不用调用再次提醒接口
180                            swal({
181                                title: '微信绑定成功!',
182                                text: '',
183                                imageUrl:  '../../../assets/images/bounced-successful.png',
184                                imageSize: '70x70',
185                                showConfirmButton: false,
186                                timer: 2000
187                            }).then(function(){
188                                that.node.$globalBindWechatModal.modal("hide");
189                                //   如果是绑定微信成功则关闭弹窗
190                                window.location.reload();
191                            });
192                        } else if (code === 404) {
193                            swal({
194                                type: 'error',
195                                title: '绑定失败!',
196                                text: state.message,
197                                showConfirmButton: false,
198                                timer: 2000
199                            }).then(function () {
200                                that.getQrCode();
201                            });
202                        }
203                    }
204                })
205            }, 1500);
206        },
207        // 判断是否输入url地址 
208        fGetAsin:function(url){
209            if (/(product[-reviews]?)|(dp)\/[A-Z0-9]{8,15}(([\/|\b|\s|\\?]+)|($))/i.test(url)) {
210                let match = url.match(/\/([A-Z0-9]{8,15})(([\/|\b|\s|\\?]+)|($))/i);
211                return match ? match[1].toUpperCase() : null;
212            }
213            return null;
214        },
215        // 截取url地址中的asin
216        fIsAtListingPage:function(url){
217            return url && this.fGetWebsite(url).indexOf('www.amazon.') >= 0 && /\/(dp|product)\/[A-Z0-9]{8,15}(([\/|\b|\s|\\?]+)|($))/i.test(url);
218        },
219        fGetWebsite:function(url){
220            let match = url.match(/(?:http(?:s)?:\/\/)?(?:www\.)?(.*?)(\.[-\w]+)+/);
221            return match ? match[0] : '';
222        },
223        detectionGetLinkAsin:function($this){
224            let val = $this.val(),linkVal = null,isLink=null,that = this;
225            let isMoreLinkAsin = $this.is(".isMoreLinkAsin") || false,queryAsins = [],parameters;
226            let errorTips = GLOBAL_MOMENT_LANGUAGE == 'jp'?'解析できない、またはリンクに有効なASINが含まれていない': (GLOBAL_MOMENT_LANGUAGE == 'en'?'The link cannot be resolved or the link does not contain any valid ASIN':'无法解析或该链接不包含有效ASIN')
227            // 支持多个asin link解析
228            if(isMoreLinkAsin){
229                let asin = $this.val(),isShowAllAsin = false,isLinkVal = false,asinParameters,
230                asinsArry = asin.split(/[,,\s]/);
231                if(asinsArry.length>1){
232                    for (var x in asinsArry){
233                        if (!asinsArry[x].trim()) continue;
234                        asinParameters = that.singleOrMultiple(asinsArry[x]);
235                        if(asinParameters.linkVal){
236                            isLinkVal = true;
237                            queryAsins.push(asinParameters.val);
238                        }else{
239                            if(asinParameters.isLink){
240                                isShowAllAsin = true;
241                                break; 
242                            }else{
243                                queryAsins.push(asinsArry[x]);
244                            }
245                        } 
246                    }
247                    if(isShowAllAsin){
248                       asinParameters.isLink?createYgtoastError(errorTips,6000):null;
249                       return;
250                    }
251                    if(!isLinkVal){
252                        return;
253                    }
254                    parameters={
255                        val:queryAsins.join(" "),
256                        linkVal:true,
257                        isLink:false
258                    };
259                }else{
260                    parameters = that.singleOrMultiple(val);
261                }
262            }else{
263                parameters = that.singleOrMultiple(val);
264            }
265            if(parameters.linkVal){
266                $this.val(parameters.val);
267            }else{
268                parameters.isLink?createYgtoastError(errorTips,6000):null;
269            }
270        },
271        singleOrMultiple:function(val){
272            linkVal = (/[,,\s]/).test(val)?false:window.ModulePublickIPSJPENCN.fIsAtListingPage(val);
273            isLink = window.ModulePublickIPSJPENCN.fGetWebsite(val),parameters={
274                val:linkVal?window.ModulePublickIPSJPENCN.fGetAsin(val):null,
275                linkVal:linkVal,
276                isLink:isLink
277            };
278            return parameters;
279        },
280        // 中文版有盗号风险的子账号提示
281        riskSubClientTips:function(){
282            swal({
283            html: "<div>您的账号有被盗风险!</div> <div>请尽快联系您的主账号管理员修改密码!</div>",
284            imageUrl:'../../../assets/images/bounced-warning.png',
285            showConfirmButton: true,
286            confirmButtonColor: '#FB8C1E',
287            confirmButtonText: '确定',
288            }).then((isConfirm) => {
289                    try {
290                        window.location.replace("/w/user/logout")
291                    } catch (e) {
292                      
293                    }
294                }
295            );
296        },
297        rentAccountTips: function () {
298            swal({
299                title: "🆘糟糕,发现你的卖家精灵账号有个安全风险……",
300                html: "<br><p style='text-align:left;'>近期发现你的账号有多人/多地使用嫌疑,这意味着你在卖家精灵上的使用记录,有可能被他人偷窥👀或利用哦!</p>" +
301                    "<p style='text-align:left;'>辛辛苦苦选到的潜力爆品或优质流量词,可不要就这样被人偷偷拿走啦。</p>" +
302                    "<p style='text-align:left;'>✅建议账号不共享,不外借;守护数据隐私,就是守护财富! </p>" +
303                    "<p style='text-align:left;'>✅请到个人中心绑定微信重新登录,这样账号更有安全保障哦!</p>",
304                width:500,
305                showConfirmButton: true,
306                confirmButtonColor: '#FB8C1E',
307                confirmButtonText: '前往个人中心',
308            }).then((isConfirm) => {
309                    try {
310                        // 标记弹窗时间
311                        localStorage.setItem('popViewModal',new Date().getTime());
312                        window.location.replace("/v2/me")
313                    } catch (e) {
314                    }
315                }
316            );
317        },
318        // 自定义事件监听
319        initCustomEventListener: function () {
320            let that = this;
321
322            // 插件版本
323            const EXT_VERSION_EVENT = 'sellersprite_ext_version';
324            window.removeEventListener(EXT_VERSION_EVENT, function () {});
325            window.addEventListener(EXT_VERSION_EVENT, function (e) {
326                const detail = e && e.detail;
327                if (null == detail) return;
328                that.node.extension = detail;
329            });
330        },
331        newBeginnerLocalStorage:function(newbie_switch, beginner_guide) {
332            newbie_switch = newbie_switch ? newbie_switch : false;
333            if (window.localStorage) {
334                let itemLen = window.localStorage.getItem(beginner_guide);
335                if (!newbie_switch) {
336                    return itemLen;
337                } else {
338                    window.localStorage.setItem(beginner_guide, newbie_switch);
339                }
340            }
341            return false;
342        }
343
344    };
345    window.ModulePublickIPSJPENCN = Fn;
346    window.ModulePublickIPSJPENCN.init();
347});
348
349//sceneTips已读
350function sceneTipsRead(sceneTipsId, sceneTipsUri) {
351    $.ajax({
352        type: 'POST',
353        url: '/v2/fragment/sceneTipsRead',
354        dataType: 'json',
355        data: {
356            id: sceneTipsId
357        },
358        async: false,
359        success: function (result) {
360            if (result.code === "OK") {
361                let sceneTipsUriClass = "." + sceneTipsUri;
362                $(sceneTipsUriClass).popover("hide").popover('dispose');
363            }
364        }
365    });
366}
367function sceneTipsReadNext(sceneTipsId, sceneTipsUri,nextUrl) {
368    $.ajax({
369        type: 'POST',
370        url: '/v2/fragment/sceneTipsRead',
371        dataType: 'json',
372        data: {
373            id: sceneTipsId
374        },
375        async: false,
376        success: function (result) {
377            if (result.code === "OK") {
378                let sceneTipsUriClass = "." + sceneTipsUri;
379                handleSetSceneTips(nextUrl)
380                $(sceneTipsUriClass).popover("hide").popover('dispose');
381             
382            }
383        }
384    });
385}
386function createYgtoastError(str,duration) {
387    let toastHtml = '<div  class="toast-content-box position-center"><div class="toast toast-error" aria-live="polite"><div class="toast-message"></div></div></div>';
388    document.querySelector(".toast-content-box")?'':$("body").append(toastHtml);    //当还没hide时禁止重复点击
389    $(".toast-content-box").fadeIn().find(".toast-message").html('<i class="iconfont icon-sigh mr-2"></i>'+str);
390    setTimeout(function(){
391        $(".toast-content-box").fadeOut();
392    },duration)
393}
394
395String.prototype.format = function () {
396    let a = this;
397    for (let b = 0; b < arguments.length; b++) {
398        a = a.replace(RegExp("\\{" + (b + 1) + "\\}", "ig"), arguments[b]);
399    }
400    return a
401};

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.