// ==UserScript== // @name 煎蛋吐槽记录器 // @namespace yunyuyuan/jandan-recorder // @version 0.0.2 // @author monkey // @description 煎蛋吐槽记录器,自动记录发送过的主题和评论 // @license MIT // @match *://*.jandan.net/* // @grant GM_addStyle // @downloadURL none // ==/UserScript== (e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const d=document.createElement("style");d.textContent=e,document.head.append(d)})(" #header .nav-items .nav-item:last-of-type{display:flex}#header .nav-items .nav-item:last-of-type .jandan-record-link{cursor:pointer}#jandan-recorder-modal{display:none;position:fixed;top:0;left:0;right:0;bottom:0;z-index:99999;background:#0009}#jandan-recorder-modal .inner{background:#fff;width:70%;height:calc(100% - 100px);min-width:400px;margin:50px auto auto;padding:10px;border-radius:12px;box-shadow:0 0 12px #0003}#jandan-recorder-modal .table-container{overflow:auto;height:100%}#jandan-recorder-modal table{width:100%;border-collapse:collapse}#jandan-recorder-modal table thead{border-radius:12px 12px 0 0}#jandan-recorder-modal table thead th{padding:10px 0;font-size:16px;position:sticky;top:0;z-index:1;background:#c8c8c8}#jandan-recorder-modal table tbody td{font-size:14px;padding:8px 0;border-bottom:1px solid rgb(218,218,218);min-width:80px} "); (function () { 'use strict'; const InterruptUrls = [ /** * TODO 文章发布: N/A */ /** * 创建 问答/树洞/随手拍/无聊图 : /api/comment/create request { author: "", email: "", comment: "", comment_post_ID: "" } response string(id) */ "/api/comment/create", /** * 楼中回复: /api/tucao/create request { content: "", comment_id?: 5637737, // 树洞id comment_post_ID: 102312 } response { "code": 0, "msg": "success", "data": { "comment_ID": 12039174, "comment_author": "xiaoc", "comment_content": "祝福!", "comment_date": "2024-03-04T15:53:55.267675774+08:00", "comment_date_int": 1709538835, "comment_post_ID": 5637795, "comment_parent": 102312, "comment_reply_ID": 0, "is_jandan_user": 0, "is_tip_user": 0, "vote_negative": 0, "vote_positive": 0 } } */ "/api/tucao/create" /** * BBS发布: /api/forum/posts request { "title": "", "content": "", "page_id": 112928 } */ // TODO "/api/forum/posts", /** * BBS吐槽: /api/forum/replies request { "content": "", "post_id": 1282, "page_id": 112928 } */ // TODO "/api/forum/replies", ]; const list = []; const StorageKey = "jandan-recorder"; function getList() { return list; } function storageInit() { try { list.splice(0, 0, ...JSON.parse(localStorage.getItem(StorageKey) || "[]")); } catch { } } function updateStorage(newItem) { newItem && list.push(newItem); localStorage.setItem(StorageKey, JSON.stringify(list)); } const ModalId = "jandan-recorder-modal"; function initUI() { const container = $("#header .nav-items .nav-item:last-of-type"); const myPost = $(""); myPost.addClass("nav-link jandan-record-link"); myPost.text("我的吐槽"); myPost.appendTo(container); const modalContainer = $("
", { id: ModalId }); const modalInner = $("
", { class: "inner" }); const tableContainer = $("
", { class: "table-container" }); const table = $(""); const headers = ["日期", "类型", "内容", "网址", "操作"]; const headerEl = $(""); const headerRow = $(""); headers.forEach(function(header) { headerRow.append($("")); modalInner.append(tableContainer.append(table)); modalContainer.append(modalInner); $("body").append(modalContainer); modalContainer.on("mousedown", () => { modalContainer.css("display", "none"); }); modalInner.on("mousedown", (e) => { e.stopPropagation(); }); myPost.on("click", () => { modalContainer.css("display", "block"); renderList(); }); } function renderList() { const list2 = getList(); const bodyEl = $(`#${ModalId} tbody`); bodyEl.empty(); if (list2.length > 0) { list2.forEach(function(item, idx) { const row = $(""); row.append($("
").text(header)); }); headerEl.append(headerRow); table.append(headerEl); table.append($("
").text(new Date(item.timestamp).toLocaleString())); row.append($("").text(item.isCreate ? "自己创建" : "评论吐槽")); row.append($("").text(item.content)); const urlCell = $(""); const link = $("").attr("href", item.url).attr("target", "_blank").text("点击前往"); urlCell.append(link); row.append(urlCell); row.append($("").append($("