去你妈的绿网计划

去除淘宝/天猫绿网计划跳转

目前為 2022-12-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         去你妈的绿网计划
// @namespace    https://www.fkj233.cn/
// @version      1.2
// @description  去除淘宝/天猫绿网计划跳转
// @author       FKJ
// @match        *://item.taobao.com/*
// @match        *://detail.tmall.com/*
// @icon         https://www.taobao.com/favicon.ico
// @grant        none
// @run-at       document-body
// @license      GPL3
// ==/UserScript==

(function() {
    'use strict';
    const originOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function (_, url) {
        if (url.indexOf("mtop.taobao.pcdetail.data.get") !== -1) {
            const xhr = this;
            const getter = Object.getOwnPropertyDescriptor(
                XMLHttpRequest.prototype,
                "response"
            ).get;
            Object.defineProperty(xhr, "responseText", {
                get: () => {
                    let result = getter.call(xhr);
                    try {
                        const res = JSON.parse(result);
                        if (res.data.pcTrade.redirectReason === "teenagerGreenNetwork") delete res.data.pcTrade;
                        return JSON.stringify(res);
                    } catch (e) {
                        return result;
                    }
                },
            });
        }
        originOpen.apply(this, arguments);
    };
    const backup = window.onSibRequestSuccess;
    window.onSibRequestSuccess = function(res) {
        if (res.data.redirectUrl.indexOf("https://market.m.taobao.com/app/msd/m-activity-life/index.html") !== -1) delete res.data.redirectUrl;
        backup(res);
    }
})();