Greasy Fork

Greasy Fork is available in English.

去淘宝小尾巴 领取自己的优惠券

Remove tail & Receive coupons

当前为 2021-02-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         去淘宝小尾巴 领取自己的优惠券
// @namespace    http://greasyfork.icu/users/91873
// @version      1.0.0.1
// @description  Remove tail & Receive coupons
// @author       wujixian
// @include      *.taobao.com/*
// @include      *.tmall.com/*
// @include      *.pub.alimama.com/*
// @match        https://pub.alimama.com/promo/search/index.htm
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
    if (window.location.pathname == "/item.htm") {
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1)
                .match(reg);
            if (r != null) return r[2];
            return null;
        }
        var site = window.location.href.match(/^http(s)?:\/\/[^?]*/);
        var wd = getQueryString("wd");
        var id = getQueryString("id");
        var q = getQueryString("q");
        var pureUrl;
        if (wd != null) {
            pureUrl = site[0] + "?wd=" + wd;
        } else if (id != null) {
            pureUrl = site[0] + "?id=" + id;
        } else if (q != null) {
            pureUrl = site[0] + "?q=" + q;
        } else if (site[0].substr(site[0].length - 13) == "view_shop.htm") {
            pureUrl = window.location.protocol + "//" + window.location.host;
        } else {
            pureUrl = site[0];
        }
        if (pureUrl != window.location.href) {
            window.history.pushState({}, 0, pureUrl );
        }
        var oDiv = document.getElementsByClassName('tb-action');
        var showBtn = '<div class="tb-btn-sku tb-btn-buy"><a href="https://pub.alimama.com/promo/search/index.htm?fn=search&q=' + pureUrl + '" target="view_window" >查询优惠券</a></div>';
        oDiv[0].innerHTML += showBtn
    }
    if (window.location.pathname == "/promo/search/index.htm") {
        var str = decodeURIComponent(window.location);
        var url = str.match(/(\S*)item.htm/)[1] + 'item.htm?id=' + (str.match(/id=(\S*)/)[1]);
        if (url != window.location.href) {
            location.href = url;
        }
    }
})();