MIUI 主题下载器

恢复 MIUI 主题官网的下载按钮

当前为 2019-09-06 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name              MIUI 主题下载器
// @namespace         https://github.com/vcheckzen/MIUIThemeDownloader
// @version           1.0.7
// @icon              http://www.xiaomi.com/favicon.ico
// @description       恢复 MIUI 主题官网的下载按钮
// @author            https://github.com/vcheckzen
// @supportURL        https://github.com/vcheckzen/MIUIThemeDownloader/issues
// @contributionURL   https://github.com/vcheckzen/MIUIThemeDownloader
// @match             *://zhuti.xiaomi.com/detail/*
// @grant             GM_xmlhttpRequest
// @run-at            document-end
// ==/UserScript==

(() => {
    'use strict';
    let O = location.href;
    const R = new RegExp('^https?://zhuti.xiaomi.com/detail/[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$');
    if (R.test(O)) {
        const F = window.atob('emh1dGkueGlhb21pLmNvbS9kZXRhaWw=');
        const L = window.atob('dGhtLm1hcmtldC54aWFvbWkuY29tL3RobS9kb3dubG9hZC92Mg==');
        GM_xmlhttpRequest({
            method: 'GET',
            url: O.replace(F, L),
            onload: res => {
                if (res.status === 200) {
                    let data = JSON.parse(res.responseText);
                    if (data.apiCode === 0) {
                        let btn = '<button class="btn-buy J_Push" type="submit">下载</button>';
                        let form = '<form class="detail-buy" action="' + data.apiData.downloadUrl + '">' + btn + '</form>';
                        $('#J-downWrap').append(form);
                    }
                }
            }
        });
    }
})();