还原PDD商家后台的加密字体

还原PDD商家后台的被加密的数字

当前为 2024-08-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         还原PDD商家后台的加密字体
// @namespace    undefined
// @version      2024-08-22
// @description  还原PDD商家后台的被加密的数字
// @author       You
// @match        https://mms.pinduoduo.com/sycm/goods_effect
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';
    var match = /src:\s*url\(data:application\/x-font-ttf;base64,(?<data>[^)]+)\)/.exec(document.head.outerHTML);
    if(match==undefined)
        return;

    GM_xmlhttpRequest({
        headers: {
            'content-type': 'application/json',
            'Authorization': 'Basic a2F5bzo4MTc4NDE4Nw=='
        },
        responseType: 'json',
        url: 'http://localhost:5234/Decode',
        data: '"'+match.groups['data']+'"',
        method: 'POST',
        onreadystatechange:function(res){
            if(res.status===200&&res.readyState===4){
                [...document.querySelectorAll('.__spider_font')].filter(s=>s.childElementCount == 0).forEach(s=>{
                    var text = s.innerHTML.split('').reduce((a,b)=>a+(res.response.result[b.charCodeAt()]??b), '');
                    s.innerHTML = text;
                })
            }
        }
    })
})();