Greasy Fork is available in English.

快捷查看微信公众号后台草稿箱文章是否发表

在文章标题后边追加醒目提示

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name         快捷查看微信公众号后台草稿箱文章是否发表
// @version      1.0
// @description  在文章标题后边追加醒目提示
// @author       weidingyi
// @match        https://mp.weixin.qq.com/cgi-bin/appmsg*action=list_card*
// @match        https://mp.weixin.qq.com/cgi-bin/appmsg*action=list*
// @grant        none
// @license MIT
// @namespace https://greasyfork.org/users/1299634
// ==/UserScript==

(function () {
    'use strict';

    // 定时发表列表
    var time_send_list;

    var get_pub_tip = function (flag, title) {
        if (flag) {
            return "<span style='color:green'> [已发表]</span>";
        } else {
            // 检查是否在定时发表列表中
            var txt = "<span style='color:red'> [未发表]</span>";
            if (time_send_list.indexOf(title) !== -1) {
                txt = "<span style='color:red'> [定时发表中]</span>";
            }
            return txt;
        }
    };

    
    var get_time_send_list =  function () {
        let api = "https://mp.weixin.qq.com/cgi-bin/home?t=home/index&token=" + window.wx.commonData.data.t + "&lang=zh_CN&f=json";
        return fetch(api)
            .then(s => s.json())
            .then(s => {
                let json_timesend_msg = JSON.parse(s.timesend_msg);
                if (json_timesend_msg.sent_list.length <= 0) {
                    return [];
                }
                let list = json_timesend_msg.sent_list[0].appmsg_info
                return list.map(item => {
                    return item.title;
                })
            })

    }

    var fetch_pub_tip = function () {
        let list = document.querySelectorAll(".weui-desktop-simple-appmsg__title")
        list.forEach(function (item, idx) {
            let tip = document.createElement("b");
            // 原始标题
            let title = item.firstElementChild.textContent;
            //去除标题中的特殊字符, 有特殊字符时,搜索不准确, 去之
            let keywords = item.textContent.replace('——', '');

            let check_api_json = "https://mp.weixin.qq.com/cgi-bin/appmsgpublish?sub=search&begin=0&count=10&token=" + window.wx.commonData.data.t + "&query=" + keywords + "&f=json";

            fetch(check_api_json)
                .then(res => res.json())
                .then(res => {
                    let json_publish_page = JSON.parse(res.publish_page);
                    let span = '';
                    if (json_publish_page.total_count > 0) {
                        span = get_pub_tip(true, title);
                    } else {
                        span = get_pub_tip(false, title);
                    }
                    tip.innerHTML = span;
                    item.appendChild(tip);
                })
        })
    }

    get_time_send_list()
        .then(res => {
            time_send_list = res;
            fetch_pub_tip();
        })
})();