// ==UserScript==
// @name 煎蛋吐槽记录器
// @namespace yunyuyuan/jandan-recorder
// @version 1.1.1
// @author yunyuyuan
// @description 煎蛋吐槽记录器,自动记录发送过的主题和评论
// @license MIT
// @icon data:image/png;base64,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
// @match *://*.jandan.net/*
// @require https://unpkg.com/[email protected]/dist/vue.global.prod.js
// @grant GM_addStyle
// @grant GM_info
// @grant unsafeWindow
// ==/UserScript==
(e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const a=document.createElement("style");a.textContent=e,document.head.append(a)})(" .table-container[data-v-1ed3a967]{overflow:auto;flex-grow:1;align-self:stretch;border:1px solid #c1c1c1}table[data-v-1ed3a967]{width:100%;border-collapse:collapse}table thead[data-v-1ed3a967]{border-radius:12px 12px 0 0}table thead th[data-v-1ed3a967]{padding:10px 0;font-size:16px;position:sticky;top:0;z-index:1;background:#c8c8c8}table tbody tr.is-child td[data-v-1ed3a967]{border-color:transparent}table tbody td[data-v-1ed3a967]{font-size:14px;padding:8px 0;border-top:1px solid rgb(218,218,218)}@media screen and (min-width: 769px){table tbody td[data-v-1ed3a967]{min-width:80px}}.settings-container{width:100%;overflow:auto}.settings-container>div{padding:20px 0;border-bottom:1px solid gray}.settings-container .github svg{height:30px;width:30px}#jandan-recorder-modal{position:fixed;top:0;left:0;right:0;bottom:0;z-index:99999;background:#0009}#jandan-recorder-modal .inner{background:#fff;color:#000;width:70%;height:calc(100% - 100px);margin:50px auto auto;padding:10px;border-radius:12px;box-shadow:0 0 12px #0003;display:flex;align-items:center;flex-direction:column}@media screen and (min-width: 769px){#jandan-recorder-modal .inner{min-width:400px}}@media screen and (max-width: 768px){#jandan-recorder-modal .inner{width:90%}}#jandan-recorder-modal .header{position:relative;margin-bottom:10px;width:100%}#jandan-recorder-modal .header .switcher{font-size:15px;padding:4px 8px;margin:auto}#jandan-recorder-modal .header .close{position:absolute;right:0;cursor:pointer}#jandan-recorder-modal .header .close svg{stroke:#000;width:25px;height:25px}#jandan-recorder-modal .header .close:hover svg{stroke:red}#header .nav-items .nav-item:last-of-type{display:flex}#header .nav-items .nav-item:last-of-type .jandan-record-link{cursor:pointer}.jandan-record-link{word-break:keep-all} ");
(function (vue) {
'use strict';
const InterceptUrls = [
/**
* TODO 文章发布: N/A
*/
/**
* 创建 问答/树洞/随手拍/无聊图 : /api/comment/create, /jandan-comment.php
request
{
author: "",
email: "",
comment: "",
comment_post_ID: ""
}
response string(id)
*/
"/api/comment/create",
"/jandan-comment.php",
/**
* 楼中回复: /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
}
response
{
"code": 0,
"msg": "success",
"data": ""
"post_id": ???
}
*/
// TODO "/api/forum/posts", 没有返回id,所以暂时不做
/**
* BBS吐槽: /api/forum/replies
request
{
"content": "",
"post_id": 1282,
"page_id": 112928
}
*/
"/api/forum/replies"
];
const OneDay = 1e3 * 60 * 60 * 24;
const ShowModalEvent = "show-modal";
const PushRecordEvent = "push-record";
const SettingsStorageKey = "jandan-recorder-settings";
const SettingsKeyAutoDeleteDay = "auto-delete-day";
const SettingsKeyAutoDelete404 = "auto-delete-404";
const SettingsKeyFoldItem = "fold-item";
const DefaultSettings = {
[SettingsKeyAutoDeleteDay]: "0",
[SettingsKeyAutoDelete404]: false,
[SettingsKeyFoldItem]: true
};
var _GM_info = /* @__PURE__ */ (() => typeof GM_info != "undefined" ? GM_info : void 0)();
var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
function mitt(n) {
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
var i = n.get(t);
i ? i.push(e) : n.set(t, [e]);
}, off: function(t, e) {
var i = n.get(t);
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
}, emit: function(t, e) {
var i = n.get(t);
i && i.slice().map(function(n2) {
n2(e);
}), (i = n.get("*")) && i.slice().map(function(n2) {
n2(t, e);
});
} };
}
const emitter = mitt();
const _window = _unsafeWindow || window;
const $ = (_window == null ? void 0 : _window.jQuery) || (_window == null ? void 0 : _window.$);
const _withScopeId = (n) => (vue.pushScopeId("data-v-1ed3a967"), n = n(), vue.popScopeId(), n);
const _hoisted_1$2 = { class: "table-container" };
const _hoisted_2$2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("br", null, null, -1));
const _hoisted_3$2 = ["onClick"];
const _hoisted_4$1 = ["href"];
const _hoisted_5$1 = ["onClick"];
const _hoisted_6$1 = { key: 0 };
const ListStorageKey = "jandan-recorder";
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
__name: "list",
props: {
inSetting: {
type: Boolean
}
},
setup(__props) {
const props = __props;
const settings = vue.readonly(vue.inject("settings"));
const list2 = vue.reactive([]);
const openedUrls = vue.reactive(/* @__PURE__ */ new Set());
const listWithFold = vue.computed(() => {
if (settings[SettingsKeyFoldItem]) {
const result = [];
for (const item of list2) {
const sameUrlItemIdx = result.findIndex((i) => i.url === item.url);
if (sameUrlItemIdx > -1) {
const sameUrlItem = result[sameUrlItemIdx];
sameUrlItem.childrenNum += 1;
result.splice(sameUrlItemIdx + sameUrlItem.childrenNum, 0, { ...item, isChild: true });
} else {
result.push({ ...item, childrenNum: 0 });
}
}
return result;
} else {
return list2;
}
});
const getListFromStorage = () => {
list2.splice(0, list2.length, ...JSON.parse(localStorage.getItem(ListStorageKey) || "[]"));
};
const saveList = () => {
localStorage.setItem(ListStorageKey, JSON.stringify(vue.toRaw(list2)));
getListFromStorage();
};
emitter.on(PushRecordEvent, (newItem) => {
if (!newItem)
return;
list2.unshift(newItem);
saveList();
});
const removeListItem = (idx) => {
list2.splice(idx, 1);
saveList();
};
const toggleOpened = (url) => {
if (openedUrls.has(url)) {
openedUrls.delete(url);
} else {
openedUrls.add(url);
}
};
vue.watch(() => props.inSetting, (inSetting) => {
if (!inSetting) {
getListFromStorage();
}
});
vue.onMounted(() => {
getListFromStorage();
const now = Date.now();
const autoDeleteDay = parseInt(settings[SettingsKeyAutoDeleteDay]);
if (typeof autoDeleteDay === "number" && autoDeleteDay > 0) {
list2.splice(0, list2.length, ...list2.filter((item) => {
return item.timestamp > now - OneDay * autoDeleteDay;
}));
}
saveList();
if (settings[SettingsKeyAutoDelete404]) {
const allUrls = new Set(list2.map((item) => item.url));
(async () => {
for (const url of allUrls) {
const biggest = list2.filter((item) => item.url === url).map((item) => item.lastCheck404 || 0).sort((a, b) => a - b).pop();
if (biggest < now - OneDay) {
const res = await fetch(url);
if (res.status === 404) {
list2.splice(0, list2.length, ...list2.filter((item) => {
return item.url !== url;
}));
}
list2.forEach((item) => {
if (item.url === url) {
item.lastCheck404 = now;
}
});
await new Promise((resolve) => setTimeout(resolve, 1e3));
}
saveList();
}
})();
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
vue.createElementVNode("table", null, [
vue.createElementVNode("thead", null, [
vue.createElementVNode("tr", null, [
(vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(["日期", "类型", "内容", "网址", "操作"], (i) => {
return vue.createElementVNode("th", null, vue.toDisplayString(i), 1);
}), 64))
])
]),
vue.createElementVNode("tbody", null, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(listWithFold.value, (item, idx) => {
return vue.openBlock(), vue.createElementBlock("tr", {
class: vue.normalizeClass({ "is-child": item.isChild })
}, [
!item.isChild || openedUrls.has(item.url) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.createElementVNode("td", null, vue.toDisplayString(new Date(item.timestamp).toLocaleString()), 1),
vue.createElementVNode("td", null, vue.toDisplayString(item.isCreate ? "楼主" : "吐槽"), 1),
vue.createElementVNode("td", null, [
vue.createTextVNode(vue.toDisplayString(item.content) + " ", 1),
vue.unref(settings)[vue.unref(SettingsKeyFoldItem)] && item.childrenNum ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
_hoisted_2$2,
vue.createElementVNode("button", {
onClick: ($event) => toggleOpened(item.url)
}, vue.toDisplayString(openedUrls.has(item.url) ? "收起" : "展开") + vue.toDisplayString(item.childrenNum) + "条", 9, _hoisted_3$2)
], 64)) : vue.createCommentVNode("", true)
]),
vue.createElementVNode("td", null, [
vue.createElementVNode("a", {
target: "_blank",
href: item.urlWithAnchor || item.url
}, "前往", 8, _hoisted_4$1)
]),
vue.createElementVNode("td", null, [
vue.createElementVNode("button", {
onClick: ($event) => removeListItem(idx)
}, "删除", 8, _hoisted_5$1)
])
], 64)) : vue.createCommentVNode("", true)
], 2);
}), 256)),
list2.length === 0 ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_6$1, "一条都没有,赶快去吐槽吧!")) : vue.createCommentVNode("", true)
])
])
]);
};
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const list = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1ed3a967"]]);
const _hoisted_1$1 = { class: "settings-container" };
const _hoisted_2$1 = { title: "每次打开网站时检查" };
const _hoisted_3$1 = { title: "每天自动检查一次" };
const _hoisted_4 = { title: "在同一个贴子下面有多个吐槽,则自动折叠,但依然可以手动展开" };
const _hoisted_5 = /* @__PURE__ */ vue.createElementVNode("p", null, [
/* @__PURE__ */ vue.createElementVNode("a", {
class: "github",
target: "_blank",
href: "https://github.com/yunyuyuan/jandan-recorder"
}, [
/* @__PURE__ */ vue.createElementVNode("svg", { viewBox: "0 0 16 16" }, [
/* @__PURE__ */ vue.createElementVNode("path", { d: "M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z" })
])
])
], -1);
const _hoisted_6 = /* @__PURE__ */ vue.createElementVNode("br", null, null, -1);
const _hoisted_7 = /* @__PURE__ */ vue.createElementVNode("span", { style: { "color": "grey", "margin": "0 10px" } }, "|", -1);
const _hoisted_8 = /* @__PURE__ */ vue.createElementVNode("a", {
target: "_blank",
href: "https://update.gf.qytechs.cn/scripts/488975/%E7%85%8E%E8%9B%8B%E5%90%90%E6%A7%BD%E8%AE%B0%E5%BD%95%E5%99%A8.user.js"
}, "检查更新", -1);
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
__name: "settings",
setup(__props) {
const settings = vue.inject("settings");
const refreshSettings = () => {
Object.assign(settings, {
...DefaultSettings,
...JSON.parse(localStorage.getItem(SettingsStorageKey) || "{}")
});
};
const updateSettings = (newSettings) => {
localStorage.setItem(SettingsStorageKey, JSON.stringify({
...vue.toRaw(settings),
...newSettings
}));
};
const inputAutoDeleteDay = (e) => {
const val = parseInt(e.target.value || "");
updateSettings({
[SettingsKeyAutoDeleteDay]: isNaN(val) || val < 1 ? "0" : val.toString()
});
};
const inputAutoDelete404 = (e) => {
updateSettings({
[SettingsKeyAutoDelete404]: e.target.checked
});
refreshSettings();
};
const toggleFoldItem = (e) => {
updateSettings({
[SettingsKeyFoldItem]: e.target.checked
});
refreshSettings();
};
vue.onMounted(() => {
refreshSettings();
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
vue.createElementVNode("div", _hoisted_2$1, [
vue.createTextVNode(" 自动删除 "),
vue.withDirectives(vue.createElementVNode("input", {
type: "number",
min: "0",
step: "1",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.unref(settings)[vue.unref(SettingsKeyAutoDeleteDay)] = $event),
onInput: inputAutoDeleteDay,
onFocusout: refreshSettings
}, null, 544), [
[vue.vModelText, vue.unref(settings)[vue.unref(SettingsKeyAutoDeleteDay)]]
]),
vue.createTextVNode(" 天前的记录(默认设置为0则不自动删除) ")
]),
vue.createElementVNode("div", _hoisted_3$1, [
vue.withDirectives(vue.createElementVNode("input", {
type: "checkbox",
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vue.unref(settings)[vue.unref(SettingsKeyAutoDelete404)] = $event),
onChange: inputAutoDelete404
}, null, 544), [
[vue.vModelCheckbox, vue.unref(settings)[vue.unref(SettingsKeyAutoDelete404)]]
]),
vue.createTextVNode(" 自动删除已失效(404)的记录 ")
]),
vue.createElementVNode("div", _hoisted_4, [
vue.withDirectives(vue.createElementVNode("input", {
type: "checkbox",
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.unref(settings)[vue.unref(SettingsKeyFoldItem)] = $event),
onChange: toggleFoldItem
}, null, 544), [
[vue.vModelCheckbox, vue.unref(settings)[vue.unref(SettingsKeyFoldItem)]]
]),
vue.createTextVNode(" 折叠主题相同的项目 ")
]),
vue.createElementVNode("div", null, [
_hoisted_5,
_hoisted_6,
vue.createElementVNode("p", null, [
vue.createTextVNode("当前版本:" + vue.toDisplayString(vue.unref(_GM_info).script.version), 1),
_hoisted_7,
_hoisted_8
])
])
]);
};
}
});
const _hoisted_1 = { class: "header" };
const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("svg", {
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, [
/* @__PURE__ */ vue.createElementVNode("path", {
d: "M21 21L12 12M12 12L3 3M12 12L21.0001 3M12 12L3 21.0001",
"stroke-width": "2",
"stroke-linecap": "round",
"stroke-linejoin": "round"
})
], -1);
const _hoisted_3 = [
_hoisted_2
];
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "modal",
setup(__props) {
const showModal = vue.ref(false);
emitter.on(ShowModalEvent, () => {
showModal.value = true;
});
const close = () => {
showModal.value = false;
};
const inSetting = vue.ref(false);
return (_ctx, _cache) => {
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
id: "jandan-recorder-modal",
onMousedown: _cache[3] || (_cache[3] = ($event) => showModal.value = false)
}, [
vue.createElementVNode("div", {
class: "inner",
onMousedown: _cache[2] || (_cache[2] = (e) => e.stopPropagation())
}, [
vue.createElementVNode("div", _hoisted_1, [
vue.createElementVNode("button", {
class: "switcher",
onClick: _cache[0] || (_cache[0] = ($event) => inSetting.value = !inSetting.value)
}, vue.toDisplayString(inSetting.value ? "返回列表(设置会自动保存)" : "前往设置"), 1),
vue.createElementVNode("span", {
class: "close",
onClick: _cache[1] || (_cache[1] = ($event) => close())
}, _hoisted_3)
]),
vue.withDirectives(vue.createVNode(list, { inSetting: inSetting.value }, null, 8, ["inSetting"]), [
[vue.vShow, !inSetting.value]
]),
vue.withDirectives(vue.createVNode(_sfc_main$1, null, null, 512), [
[vue.vShow, inSetting.value]
])
], 32)
], 544)), [
[vue.vShow, showModal.value]
]);
};
}
});
function processResponse(url, requestData, res) {
let item = null;
const now = Date.now();
switch (url) {
case "/jandan-comment.php":
case "/api/comment/create":
item = {
url: `/t/${res}`,
urlWithAnchor: `/t/${res}`,
isCreate: true,
content: requestData.comment,
timestamp: now,
lastCheck404: now
};
break;
case "/api/tucao/create":
if (res.msg == "success") {
const isPost = _window.location.pathname.startsWith("/p/");
item = {
url: isPost ? `/p/${requestData.comment_post_ID}` : `/t/${requestData.comment_id}`,
urlWithAnchor: isPost ? `/p/${requestData.comment_post_ID}#${res.data.comment_ID}` : `/t/${requestData.comment_id}#tucao-${res.data.comment_ID}`,
isCreate: false,
content: requestData.content,
timestamp: now,
lastCheck404: now
};
}
break;
case "/api/forum/replies":
if (res.msg == "success") {
item = {
url: `/bbs#/topic/${requestData.post_id}`,
urlWithAnchor: `/bbs#/topic/${requestData.post_id}`,
isCreate: false,
content: requestData.content,
timestamp: now,
lastCheck404: now
};
}
break;
}
item && emitter.emit(PushRecordEvent, item);
}
function parseRequestData(requestData) {
let result = requestData;
const parsedObj = {};
if (typeof requestData == "string") {
try {
return JSON.parse(requestData);
} catch {
for (const [key, value] of new URLSearchParams(requestData)) {
parsedObj[key] = value;
}
result = parsedObj;
}
} else if (requestData instanceof FormData) {
requestData.forEach(function(value, key) {
parsedObj[key] = value;
});
result = parsedObj;
}
return result;
}
if ($) {
$(document).on("ajaxSuccess", function(_event, _jqXHR, settings, data) {
try {
const url = settings.url;
if (InterceptUrls.includes(url)) {
processResponse(url, parseRequestData(settings.data), data);
}
} catch {
}
});
}
if (_window.axios) {
_window.axios.interceptors.response.use((response) => {
try {
processResponse(response.config.url, parseRequestData(response.config.data), response.data);
} catch {
}
return response;
});
}
const App = vue.createApp(_sfc_main);
App.provide("settings", vue.reactive({
...DefaultSettings,
...JSON.parse(localStorage.getItem(SettingsStorageKey) || "{}")
}));
App.mount(
(() => {
const app = document.createElement("div");
document.body.append(app);
return app;
})()
);
const memberLink = document.querySelector('a[href="/member"]');
const myPost = document.createElement("a");
myPost.classList.add("nav-link", "jandan-record-link");
myPost.innerText = "我的吐槽";
myPost.onclick = () => {
emitter.emit(ShowModalEvent);
};
memberLink.parentElement.appendChild(myPost);
if (_window.location.pathname === "/bbs") {
fetch("/api/member/get_info").then((res) => {
if (res.ok) {
res.json().then((res2) => {
var _a;
if (res2.data.id) {
const myBbs = document.createElement("a");
myBbs.innerText = "我的贴子";
myBbs.href = `/bbs#/user/${res2.data.id}`;
myBbs.target = "_blank";
(_a = document.querySelector(".list-header")) == null ? void 0 : _a.appendChild(myBbs);
}
});
}
});
}
console.log("煎蛋吐槽记录器加载成功!");
})(Vue);