购物党比价脚本 TENG

仅在html标签中插入购物党官方js脚本,不含其他个人广告

目前为 2021-02-12 提交的版本。查看 最新版本

// ==UserScript==
// @name         购物党比价脚本 TENG
// @namespace    none
// @version      1.1beta
// @description  仅在html标签中插入购物党官方js脚本,不含其他个人广告
// @author       teng
// @include      http*://item.taobao.com/*
// @include      http*://detail.tmall.com/item.htm*
// @include      http*://chaoshi.detail.tmall.com/item.htm*
// @connect      gwdang.com
// @run-at       document-start
// @license      GPL-3.0-only
// ==/UserScript==
(function () {
            function addStyle(css) { //
                var pi = document.createProcessingInstruction(
                    'xml-stylesheet',
                    'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
                );
                return document.insertBefore(pi, document.documentElement);
            }

            function addScript(src) {
                let node = document.createElement("script");
                node.src = src;
                node.charset = "UTF-8";
                document.head.appendChild(node);
            }

            function initGWD() {
                let extName = "gwdv1.js";
                var hideStyle = "";
                if (location.host == "jd.com") {
                    extName = "gwdv2.js";
                    hideStyle = ".gwd-minibar-bg, #favor_box{display:none !important;}" +
                        "#gwdang_main > a.gwd-topbar-logo, #gwdang_main > div.gwd-topbar-right{display:none !important;}";
                } else {
                    hideStyle =
                        "#gwdang-main>div.logo, #gwdang-feed-close, #gwdang-history, #coupon_box, #bjd_yifenqian_detail{display:none !important}" +
                        "#favor_box{display:none !important;}#tb-amount .tb-count{font-weight:bold;margin:0 5px;}";
                }
                addScript("https://cdn.gwdang.com/js/gwdang-notifier.js");  
                //官方js文件备份https://browser.gwdang.com/get.js?f=/js/gwdang_extension.js
                //官方插件介绍页https://www.gwdang.com/app/extension?page=question
                //addStyle(hideStyle);
            }
    initGWD();
        })()