// ==UserScript==
// @name V2EX - 超级增强
// @namespace http://tampermonkey.net/
// @version 3.2
// @description 最完整的楼中楼回复(支持按感谢排序),在列表可预览帖子内容,列表点击帖子弹出帖子详情,划词 base64 解码,自动加载下一页,操作按钮(感谢、收藏、回复、隐藏)异步请求,不会刷新页面,支持黑暗模式
// @author Zyronon
// @match https://*.v2ex.com/
// @match https://*.v2ex.com/?tab=*
// @match https://*.v2ex.com/t/*
// @match https://*.v2ex.com/recent*
// @match https://*.v2ex.com/go/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @require https://cdn.bootcdn.net/ajax/libs/vue/3.2.47/vue.runtime.global.prod.min.js
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_openInTab
// @license GPL License
// ==/UserScript==
(function () {
let style = `
html,body{font-size:62.5%}.flex{display:flex;align-items:center;justify-content:space-between}.flex-end{justify-content:flex-end}.flex-center{justify-content:center}.p1{padding:1rem}.p0{padding:0!important}.post-author{display:flex;align-items:center;position:relative;color:#ccc!important}.post-author>.username{font-size:1.2rem}.sticky{position:sticky;bottom:0}.sticky[stuck]{box-shadow:0 2px 20px #00000059}a{color:#778087;text-decoration:none;cursor:pointer}a:hover{text-decoration:underline}.base-loading{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear}.loading-c{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;width:3rem;height:3rem}.loading-b{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:#ffffff rgba(178,177,177,.2) rgba(178,177,177,.2) rgba(178,177,177,.2);width:3rem;height:3rem}@keyframes circle{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.button{cursor:pointer;padding:.4rem 2.4rem;border-radius:5px;display:inline-flex;justify-content:center;align-items:center;font-weight:700;font-size:1.2rem;color:#fff;background:#40a9ff;border:1px solid #40a9ff;user-select:none}.button.info{color:#000;border:1px solid #40a9ff;background:white}.button.gray{color:#fff;border:1px solid #b6b6b6;background:#b6b6b6}.button:hover{opacity:.9}.button:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:#fff transparent transparent transparent;width:1rem;height:1rem;margin-right:1rem;display:none}.button.loading{cursor:not-allowed;opacity:.5}.button.loading:before{display:block}.button.disabled{cursor:not-allowed;color:#c6c6c6;background:#8d8d8d;border:1px solid transparent}.tool{position:relative;margin-left:.6rem;display:flex;align-items:center;font-size:1.2rem;font-weight:700;border-radius:.2rem;cursor:pointer;height:3rem;padding:0 .5rem}.tool:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle infinite 1s linear;border-color:transparent #929596 #929596 #929596;width:1rem;height:1rem;margin-left:1rem;display:none}.tool.loading{cursor:not-allowed;opacity:.5}.tool.loading:before{display:block}.tool.loading:hover{background:unset}.tool>svg{width:1.6rem!important;height:1.6rem!important;margin-right:.4rem;box-sizing:border-box;border-radius:.2rem}.tool:hover{background:#e8e8e8}.tool.no-hover{cursor:default}.tool.no-hover:hover{background:unset}.my-node{border-radius:.2rem;padding:.4rem;font-size:1rem;color:#999;background:#f5f5f5;cursor:pointer}.my-node:hover{text-decoration:none;background:#e2e2e2}.msgs{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.msg{cursor:default;margin-bottom:2rem;background:white;display:flex;color:#000;font-size:1.4rem;box-sizing:border-box;border-radius:.4rem;box-shadow:0 0 1rem 1px silver}.msg.success .left{background:#40a9ff}.msg.warning .left{background:#c8c002}.msg.error .left{background:red}.msg .left{border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#40a9ff}.msg .left svg{margin:0 .3rem;cursor:pointer}.msg .right{flex:1;padding:1rem 2rem;display:flex;justify-content:space-between;align-items:center}.line{border-bottom:1px solid #e2e2e2}.my-box{box-shadow:0 2px 3px #0000001a;border-radius:.4rem;background:white;margin-bottom:2rem;width:100%;box-sizing:border-box}.my-cell{padding:1rem;font-size:1.4rem;line-height:150%;text-align:left;border-bottom:1px solid #e2e2e2}.f14{font-size:1.4rem}.switch{width:4.5rem;height:2.2rem;border-radius:2rem;position:relative;display:flex;align-items:center;background:#ccc;transition:all .3s}.switch.active{background:#40a9ff}.switch.active:before{right:.2rem}.switch:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%;background:white}.modal{position:fixed;z-index:100;width:100vw;height:100vh;left:0;top:0;display:flex;justify-content:center;align-items:center}.modal .title{font-size:2.4rem;margin-bottom:1rem;text-align:center}.modal .option{display:flex;justify-content:space-between;align-items:center;padding:.8rem 0}.modal .mask{position:fixed;width:100vw;height:100vh;left:0;top:0;background:rgba(0,0,0,.3)}.radio-group2{display:inline-flex;border-radius:.5rem;overflow:hidden;border:1px solid #e2e2e2}.radio-group2 .radio{cursor:pointer;background:transparent;padding:.5rem 1.5rem;border-left:1px solid #e2e2e2;color:#9ca1a4}.radio-group2 .radio:first-child{border-left:none}.radio-group2 .active{background:#e2e2e2;color:gray}.horizontal[data-v-42c72dce]{flex-direction:row!important;padding:0!important}.horizontal .num[data-v-42c72dce]{margin-left:.2rem}.point[data-v-42c72dce]{font-size:1.2rem;padding:1rem 0;min-width:4rem;border-radius:.4rem 0 0 .4rem;display:flex;flex-direction:column;align-items:center}.point .up[data-v-42c72dce]{display:flex;flex-direction:column;align-items:center;justify-content:center}.point .num[data-v-42c72dce]{font-weight:700;color:#000;user-select:none}.point svg[data-v-42c72dce]{width:2rem;padding:.4rem;border-radius:.2rem}.point svg[data-v-42c72dce]:hover{background:#e5e5e5}.point .disabled[data-v-42c72dce]:hover{background:unset}.Author[data-v-c55a5484]{display:flex;align-items:center;justify-content:space-between;font-size:1.2rem;position:relative;margin-bottom:.4rem}.Author.expand[data-v-c55a5484]{margin-bottom:0}.Author .Author-left[data-v-c55a5484]{display:flex;align-items:center;max-width:90%}.Author .Author-left .username[data-v-c55a5484]{font-size:1.4rem;margin-right:1rem}.Author .Author-left .expand-icon[data-v-c55a5484]{cursor:pointer;margin-right:.8rem;width:2rem;height:2rem;transform:rotate(90deg)}.Author .Author-left .icon[data-v-c55a5484]{margin-right:1rem;display:flex}.Author .Author-left .icon img[data-v-c55a5484]{width:3.4rem;height:3.4rem;border-radius:.3rem}.Author .Author-left .texts[data-v-c55a5484]{flex:1}.Author .Author-left .op[data-v-c55a5484]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;margin-right:1rem;transform:scale(.8)}.Author .Author-left .mod[data-v-c55a5484]{display:inline-block;background-color:transparent;color:#1484cd;border-radius:.3rem;padding:0 .3rem;cursor:default;border:2px solid #1484cd;font-size:1.2rem;font-weight:700;transform:scale(.8);background:#1484cd;color:#fff;margin-right:1rem}.Author .Author-left .my-tag[data-v-c55a5484]{font-size:1.3rem;font-weight:700;color:red;margin-left:1rem}.Author .Author-left .my-tag:hover .remove[data-v-c55a5484]{display:inline}.Author .Author-left .my-tag .remove[data-v-c55a5484]{cursor:pointer;margin-left:.5rem;display:none}.Author .Author-left .add-tag[data-v-c55a5484]{font-size:2rem;line-height:1rem;display:inline-block;margin-left:1rem;cursor:pointer;display:none}.Author:hover .add-tag[data-v-c55a5484]{display:inline-block}.Author .Author-right[data-v-c55a5484]{position:absolute;right:0;display:flex;align-items:center}.Author .Author-right .toolbar[data-v-c55a5484]{display:flex;align-items:center;color:#929596;opacity:0}.Author .Author-right .toolbar[data-v-c55a5484]:hover{background:white;opacity:1}.Author .Author-right .floor[data-v-c55a5484]{margin-left:1rem;font-size:1.2rem;line-height:1rem;border-radius:1rem;display:inline-block;background-color:#f0f0f0;color:#ccc;padding:.2rem .5rem;cursor:default}.Author .Author-right .isDev[data-v-c55a5484]{color:#000!important}.post-editor-wrapper[data-v-42e79b0b]{width:100%;box-sizing:border-box;position:relative;overflow:hidden;transition:all .3s}.post-editor-wrapper.reply-post .post-editor[data-v-42e79b0b]{border:1px solid #e2e2e2;border-radius:.4rem}.post-editor-wrapper.reply-post.isFocus .post-editor[data-v-42e79b0b]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment[data-v-42e79b0b]{border:1px solid #e2e2e2;border-radius:.4rem;overflow:hidden}.post-editor-wrapper.reply-comment.isFocus[data-v-42e79b0b]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment .toolbar[data-v-42e79b0b]{background:#f6f7f8}.post-editor-wrapper .post-editor[data-v-42e79b0b]{transition:border .3s;width:100%;max-width:100%;padding:.6rem 1.4rem;box-sizing:border-box;border:none;outline:none;font-family:Avenir,Helvetica,Arial,sans-serif;font-size:1.4rem;min-height:13rem;resize:none}.post-editor-wrapper .toolbar[data-v-42e79b0b]{box-sizing:border-box;padding:.5rem 1rem;width:100%;position:relative;display:flex;justify-content:space-between;align-items:center}.post-editor-wrapper .toolbar span[data-v-42e79b0b]{color:gray;font-size:1.3rem}.post-editor-wrapper .get-cursor[data-v-42e79b0b]{transition:border .3s;width:100%;max-width:100%;padding:.6rem 1.4rem;box-sizing:border-box;border:none;outline:none;font-family:Avenir,Helvetica,Arial,sans-serif;font-size:1.4rem;min-height:13rem;resize:none;position:absolute;top:0;z-index:-100}html[data-v-ed134fcc],body[data-v-ed134fcc]{font-size:62.5%}.flex[data-v-ed134fcc]{display:flex;align-items:center;justify-content:space-between}.flex-end[data-v-ed134fcc]{justify-content:flex-end}.flex-center[data-v-ed134fcc]{justify-content:center}.p1[data-v-ed134fcc]{padding:1rem}.p0[data-v-ed134fcc]{padding:0!important}.post-author[data-v-ed134fcc]{display:flex;align-items:center;position:relative;color:#ccc!important}.post-author>.username[data-v-ed134fcc]{font-size:1.2rem}.sticky[data-v-ed134fcc]{position:sticky;bottom:0}.sticky[stuck][data-v-ed134fcc]{box-shadow:0 2px 20px #00000059}a[data-v-ed134fcc]{color:#778087;text-decoration:none;cursor:pointer}a[data-v-ed134fcc]:hover{text-decoration:underline}.base-loading[data-v-ed134fcc]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-ed134fcc infinite 1s linear}.loading-c[data-v-ed134fcc]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-ed134fcc infinite 1s linear;width:3rem;height:3rem}.loading-b[data-v-ed134fcc]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-ed134fcc infinite 1s linear;border-color:#ffffff rgba(178,177,177,.2) rgba(178,177,177,.2) rgba(178,177,177,.2);width:3rem;height:3rem}@keyframes circle-ed134fcc{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.button[data-v-ed134fcc]{cursor:pointer;padding:.4rem 2.4rem;border-radius:5px;display:inline-flex;justify-content:center;align-items:center;font-weight:700;font-size:1.2rem;color:#fff;background:#40a9ff;border:1px solid #40a9ff;user-select:none}.button.info[data-v-ed134fcc]{color:#000;border:1px solid #40a9ff;background:white}.button.gray[data-v-ed134fcc]{color:#fff;border:1px solid #b6b6b6;background:#b6b6b6}.button[data-v-ed134fcc]:hover{opacity:.9}.button[data-v-ed134fcc]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-ed134fcc infinite 1s linear;border-color:#fff transparent transparent transparent;width:1rem;height:1rem;margin-right:1rem;display:none}.button.loading[data-v-ed134fcc]{cursor:not-allowed;opacity:.5}.button.loading[data-v-ed134fcc]:before{display:block}.button.disabled[data-v-ed134fcc]{cursor:not-allowed;color:#c6c6c6;background:#8d8d8d;border:1px solid transparent}.tool[data-v-ed134fcc]{position:relative;margin-left:.6rem;display:flex;align-items:center;font-size:1.2rem;font-weight:700;border-radius:.2rem;cursor:pointer;height:3rem;padding:0 .5rem}.tool[data-v-ed134fcc]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-ed134fcc infinite 1s linear;border-color:transparent #929596 #929596 #929596;width:1rem;height:1rem;margin-left:1rem;display:none}.tool.loading[data-v-ed134fcc]{cursor:not-allowed;opacity:.5}.tool.loading[data-v-ed134fcc]:before{display:block}.tool.loading[data-v-ed134fcc]:hover{background:unset}.tool>svg[data-v-ed134fcc]{width:1.6rem!important;height:1.6rem!important;margin-right:.4rem;box-sizing:border-box;border-radius:.2rem}.tool[data-v-ed134fcc]:hover{background:#e8e8e8}.tool.no-hover[data-v-ed134fcc]{cursor:default}.tool.no-hover[data-v-ed134fcc]:hover{background:unset}.my-node[data-v-ed134fcc]{border-radius:.2rem;padding:.4rem;font-size:1rem;color:#999;background:#f5f5f5;cursor:pointer}.my-node[data-v-ed134fcc]:hover{text-decoration:none;background:#e2e2e2}.msgs[data-v-ed134fcc]{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.msg[data-v-ed134fcc]{cursor:default;margin-bottom:2rem;background:white;display:flex;color:#000;font-size:1.4rem;box-sizing:border-box;border-radius:.4rem;box-shadow:0 0 1rem 1px silver}.msg.success .left[data-v-ed134fcc]{background:#40a9ff}.msg.warning .left[data-v-ed134fcc]{background:#c8c002}.msg.error .left[data-v-ed134fcc]{background:red}.msg .left[data-v-ed134fcc]{border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#40a9ff}.msg .left svg[data-v-ed134fcc]{margin:0 .3rem;cursor:pointer}.msg .right[data-v-ed134fcc]{flex:1;padding:1rem 2rem;display:flex;justify-content:space-between;align-items:center}.line[data-v-ed134fcc]{border-bottom:1px solid #e2e2e2}.my-box[data-v-ed134fcc]{box-shadow:0 2px 3px #0000001a;border-radius:.4rem;background:white;margin-bottom:2rem;width:100%;box-sizing:border-box}.my-cell[data-v-ed134fcc]{padding:1rem;font-size:1.4rem;line-height:150%;text-align:left;border-bottom:1px solid #e2e2e2}.f14[data-v-ed134fcc]{font-size:1.4rem}.switch[data-v-ed134fcc]{width:4.5rem;height:2.2rem;border-radius:2rem;position:relative;display:flex;align-items:center;background:#ccc;transition:all .3s}.switch.active[data-v-ed134fcc]{background:#40a9ff}.switch.active[data-v-ed134fcc]:before{right:.2rem}.switch[data-v-ed134fcc]:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%;background:white}.modal[data-v-ed134fcc]{position:fixed;z-index:100;width:100vw;height:100vh;left:0;top:0;display:flex;justify-content:center;align-items:center}.modal .title[data-v-ed134fcc]{font-size:2.4rem;margin-bottom:1rem;text-align:center}.modal .option[data-v-ed134fcc]{display:flex;justify-content:space-between;align-items:center;padding:.8rem 0}.modal .mask[data-v-ed134fcc]{position:fixed;width:100vw;height:100vh;left:0;top:0;background:rgba(0,0,0,.3)}.radio-group2[data-v-ed134fcc]{display:inline-flex;border-radius:.5rem;overflow:hidden;border:1px solid #e2e2e2}.radio-group2 .radio[data-v-ed134fcc]{cursor:pointer;background:transparent;padding:.5rem 1.5rem;border-left:1px solid #e2e2e2;color:#9ca1a4}.radio-group2 .radio[data-v-ed134fcc]:first-child{border-left:none}.radio-group2 .active[data-v-ed134fcc]{background:#e2e2e2;color:gray}.html-wrapper[data-v-ed134fcc]{position:relative}.html-wrapper .mask[data-v-ed134fcc]{max-height:90rem;overflow:hidden;-webkit-mask-image:linear-gradient(180deg,#000 80%,transparent)}.html-wrapper .expand[data-v-ed134fcc]{position:absolute;z-index:1;bottom:2rem;padding:.2rem 1.5rem;border-radius:2rem;border:1px solid gray;background:white;color:gray;left:50%;transform:translate(-50%);cursor:pointer}.comment[data-v-6a750f0d]{width:100%;box-sizing:border-box;margin-top:1rem;background:white}.comment .comment-content-w[data-v-6a750f0d]{background:white}.comment .comment-content-w .more[data-v-6a750f0d]{text-align:center;margin:2rem 0}.comment .comment-content[data-v-6a750f0d]{display:flex;position:relative}.comment .comment-content .expand-line[data-v-6a750f0d]{cursor:pointer;width:3rem;min-width:3rem;position:relative}.comment .comment-content .expand-line[data-v-6a750f0d]:after{position:absolute;left:calc(60% - 1px);content:" ";height:100%;width:0;border-right:1px solid #f1f1f1}.comment .comment-content .expand-line[data-v-6a750f0d]:hover:after{border-right:2px solid #0079D3}.comment .comment-content .right[data-v-6a750f0d]{flex:1;width:calc(100% - 3rem)}.comment .comment-content .right .w[data-v-6a750f0d]{padding-left:1.7rem}.comment .comment-content .right .w .text[data-v-6a750f0d]{color:#000;word-break:break-word}.comment .comment-content .right .w .post-editor-wrapper[data-v-6a750f0d]{margin-top:1rem}.toolbar[data-v-1f833fb4]{display:flex;align-items:center;color:#929596}.toolbar .tooltip[data-v-1f833fb4]{box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;background:white;padding:1rem;top:4rem;left:-3rem;width:15rem;position:absolute;z-index:99}.toolbar .tooltip a[data-v-1f833fb4]{color:#40a9ff!important}.sticky{position:sticky;bottom:-2px}.sticky[stuck]{box-shadow:0 2px 20px #00000059!important}.post-detail[data-v-b3448560]{text-align:start;position:fixed;z-index:99;left:0;right:0;bottom:0;top:0;background:rgba(46,47,48,.8);overflow:auto;font-size:1.4rem;display:flex;justify-content:center;flex-wrap:wrap}.post-detail.isNight[data-v-b3448560]{background:rgba(46,47,48,.8)}.post-detail.isNight .main[data-v-b3448560]{background:#22303f}.post-detail.isNight .main .my-box[data-v-b3448560]{color:#fff;background:#18222d}.post-detail.isNight .main .my-box .title[data-v-b3448560],.post-detail.isNight .main .my-box .content[data-v-b3448560]{color:#d1d5d9!important}.post-detail.isNight .main .my-box .base-info[data-v-b3448560],.post-detail.isNight .main .my-box .content[data-v-b3448560]{border:1px solid #22303f!important}.post-detail.isNight .main[data-v-b3448560] .subtle .fade{color:#b2c3d4!important}.post-detail.isNight .main[data-v-b3448560] .subtle .topic_content{color:#d1d5d9!important}.post-detail.isNight .main .my-cell[data-v-b3448560]{border-bottom:1px solid #22303f!important}.post-detail.isNight .main[data-v-b3448560] .comment{background:#18222d}.post-detail.isNight .main[data-v-b3448560] .comment .expand-line:after{border-right:1px solid #202c39!important}.post-detail.isNight .main[data-v-b3448560] .comment .expand-line:hover:after{border-right:2px solid #0079D3!important}.post-detail.isNight .main[data-v-b3448560] .comment .comment-content{background:#18222d!important}.post-detail.isNight .main[data-v-b3448560] .comment .comment-content .w>.text{color:#d1d5d9!important}.post-detail.isNight .main[data-v-b3448560] .Author-right .toolbar:hover{background:#18222d!important}.post-detail.isNight .main[data-v-b3448560] .Author-right .tool{background:#22303f!important}.post-detail.isNight .main[data-v-b3448560] .point{margin-left:.5rem}.post-detail.isNight .main[data-v-b3448560] .point svg:hover{background:#22303f}.post-detail.isNight .main[data-v-b3448560] .point .num{color:#d1d5d9!important}.post-detail.isNight .main[data-v-b3448560] .floor{background:#393f4e!important;color:#d1d5d9!important}.post-detail.isNight .main .editor-wrapper[data-v-b3448560]{background:#393f4e!important}.post-detail.isNight .main[data-v-b3448560] .post-editor-wrapper .post-editor{background:#18222d;border:transparent;color:#fff}.post-detail.isNight .main[data-v-b3448560] .post-editor-wrapper .toolbar{background:#393f4e!important}.post-detail.isNight .main .call-list[data-v-b3448560]{background:#22303f}.post-detail.isNight .main .call-list .call-item[data-v-b3448560]{border-top:1px solid #18222d}.post-detail.isNight .main .call-list .call-item .select[data-v-b3448560],.post-detail.isNight .main .call-list .call-item[data-v-b3448560]:hover,.post-detail.isNight .main .call-list .call-item.select[data-v-b3448560]{background-color:#393f4e;text-decoration:none}.post-detail .main[data-v-b3448560]{display:flex;justify-content:flex-end;padding:3rem 8rem 15rem;background:#e2e2e2;position:relative}.post-detail .main .main-wrapper[data-v-b3448560]{width:77rem;padding-bottom:2rem;display:flex;flex-direction:column;align-items:center}.post-detail .main .main-wrapper .post-wrapper .toolbar-wrapper[data-v-b3448560]{border-top:1px solid #e2e2e2;height:4rem;padding-left:.6rem;display:flex;align-items:center}.post-detail .main .main-wrapper .editor-wrapper .float[data-v-b3448560]{margin-right:2rem}.post-detail .main .main-wrapper .editor-wrapper .w[data-v-b3448560]{padding:1.2rem}.post-detail .main .main-wrapper .comment-wrapper .comments[data-v-b3448560]{width:100%;box-sizing:border-box}.post-detail .main .main-wrapper .loading-wrapper[data-v-b3448560]{height:20rem;display:flex;justify-content:center;align-items:center}.post-detail .main .main-wrapper #no-comments-yet[data-v-b3448560]{color:#a9a9a9;font-weight:700;text-align:center;width:100%;margin-bottom:2rem;box-sizing:border-box}.post-detail .main .call-list[data-v-b3448560]{z-index:9;position:absolute;top:12rem;border:1px solid #ccc;background-color:#fff;box-shadow:0 5px 15px #0000001a;overflow:hidden;max-height:30rem;min-width:8rem;box-sizing:content-box}.post-detail .main .call-list .call-item[data-v-b3448560]{border-top:1px solid #ccc;height:3rem;display:flex;padding:0 1rem;align-items:center;cursor:pointer;font-size:14px;box-sizing:border-box}.post-detail .main .call-list .call-item .select[data-v-b3448560],.post-detail .main .call-list .call-item[data-v-b3448560]:hover,.post-detail .main .call-list .call-item.select[data-v-b3448560]{background-color:#f0f0f0;text-decoration:none}.post-detail .main .call-list .call-item[data-v-b3448560]:nth-child(1){border-top:1px solid transparent}@media screen and (max-width: 1500px){.post-detail .main-wrapper[data-v-b3448560]{width:65vw!important}}@media screen and (max-width: 1280px){.post-detail .main-wrapper[data-v-b3448560]{width:75vw!important}}.post-detail .scroll-top[data-v-b3448560]{position:fixed;bottom:3rem;z-index:99;padding:.4rem 1.4rem;transform:translate(6rem)}.post-detail .close-btn[data-v-b3448560]{color:#b6b6b6;cursor:pointer;position:fixed;top:3rem;transform:translate(4rem);font-size:2rem}p:first-child{margin-top:0}p:last-child{margin-bottom:0}.post[data-v-71df4ceb]{font-size:1.4rem;background:white;text-align:start;padding:1rem;overflow:hidden}.post.isNight[data-v-71df4ceb]{background:#18222d;border:none!important}.post.isNight .title a[data-v-71df4ceb]{color:#a9bcd6!important}.post.isNight .bottom .date[data-v-71df4ceb]{color:#738292}.post.isNight .post-content-wrapper[data-v-71df4ceb]{color:#d1d5d9!important}.post.isNight .my-node[data-v-71df4ceb]{background:#393f4e;color:#9caec7}.post.isNight .my-node[data-v-71df4ceb]:hover{background:#9caec7;color:#001d25}.post.isNight .count[data-v-71df4ceb]{background:#393f4e!important;color:#d1d5d9!important}.post.isNight.visited .count[data-v-71df4ceb]{background:#001d25!important;color:#393f4e!important}.post.isNight.visited .title a[data-v-71df4ceb]{color:#393f4e!important}.post.isNight.visited .post-content-wrapper[data-v-71df4ceb]{color:#576077!important}.post.table[data-v-71df4ceb]{border-bottom:1px solid #e2e2e2}.post.table .post-content-wrapper[data-v-71df4ceb]{display:none}.post.table .title a[data-v-71df4ceb]{color:#778087;font-size:1.6rem}.post.card[data-v-71df4ceb]{margin-top:1.1rem;border:1px solid #e2e2e2;border-radius:.4rem;cursor:pointer}.post.card[data-v-71df4ceb]:hover{border:1px solid #968b8b}.post.card .title a[data-v-71df4ceb]{color:#000;font-size:1.8rem}.post.visited .title a[data-v-71df4ceb]{color:#afb9c1!important}.post.visited .post-content-wrapper[data-v-71df4ceb]{opacity:.6}.post .base-info[data-v-71df4ceb]{box-sizing:border-box;display:flex;justify-content:space-between;align-items:flex-start}.post .base-info .left[data-v-71df4ceb]{display:flex;width:95%}.post .base-info .left .avatar[data-v-71df4ceb]{margin-right:1rem}.post .base-info .left .avatar img[data-v-71df4ceb]{border-radius:.4rem;width:4.8rem;min-width:4.8rem;min-height:4.8rem}.post .base-info .left .right[data-v-71df4ceb]{display:flex;flex-direction:column;justify-content:space-between}.post .base-info .left .right .title[data-v-71df4ceb]{display:inline;align-items:center}.post .base-info .left .right .bottom[data-v-71df4ceb]{font-size:1.2rem;line-height:1.2rem;display:flex;align-items:center;color:#ccc}.post .base-info .count[data-v-71df4ceb]{margin-top:1.8rem;line-height:12px;font-weight:700;color:#fff;background-color:#aab0c6;display:inline-block;padding:2px 10px;-moz-border-radius:12px;-webkit-border-radius:12px;border-radius:12px;text-decoration:none;cursor:pointer}.post .base-info .count[data-v-71df4ceb]:hover{background-color:#969cb1}.post .post-content-wrapper[data-v-71df4ceb]{max-height:20rem;overflow:hidden;margin-top:.6rem;color:#000;position:relative;line-break:anywhere;font-size:1.4rem}.post .post-content-wrapper.mask[data-v-71df4ceb]{-webkit-mask-image:linear-gradient(180deg,#000 60%,transparent)}.base64_tooltip[data-v-2d42a498]{box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d;background:white;min-height:2.2rem;max-width:20rem;padding:.8rem;position:fixed;z-index:9998;display:flex;align-items:center;border-radius:.5rem;cursor:pointer;line-break:anywhere}.base64_tooltip svg[data-v-2d42a498]{margin-left:1rem;min-width:1.8rem}.base64_tooltip .button[data-v-2d42a498]{margin-top:1rem;margin-left:2rem}.app-home{position:relative}.app-home.home,.app-home.recent,.app-home.nodePage{background:#e2e2e2}.app-home.isNight{background:#22303f}.app-home.isNight .open-post,.app-home.isNight .nav{color:#fff;background:#18222d;border:none}.app-home.isNight .setting-modal .wrapper{background:#22303f}.app-home.isNight .setting-modal .wrapper .option{color:#000}.app-home.isNight .setting-modal .wrapper .option span{color:gray!important}.app-home.isNight .radio-group2{border:1px solid #454847}.app-home.isNight .radio-group2 .radio{border-left:1px solid #454847;color:#fff}.app-home.isNight .radio-group2 .active{background:#165c94}.page.card{margin-top:1rem}.nav{font-size:1.4rem;background:white;text-align:start;padding:1rem;border:1px solid #e2e2e2}.nav .nav-item{cursor:pointer;display:flex;margin-right:2rem;padding:.6rem;border-radius:.4rem;color:#778087}.nav .nav-item.active{background:#40a9ff;color:#fff}.nav .nav-item.active:hover{background:#40a9ff;opacity:.8}.nav .nav-item:hover{background:#e2e2e2}.nav .nav-item span{margin-left:.4rem}.setting-modal .wrapper{z-index:9;background:#f1f1f1;border-radius:.8rem;font-size:1.4rem;padding:2rem 6rem 4rem;width:45rem}.setting-modal .wrapper .sub-title{color:gray;font-size:1.4rem;margin-bottom:4rem}.setting-modal .wrapper .notice{font-size:12px;display:flex;flex-direction:column;justify-content:flex-start;padding-left:3rem;line-break:anywhere;text-align:left}.setting-modal .wrapper .jieshao{margin-top:2rem;font-size:15px;font-weight:700;color:red;display:flex;justify-content:flex-start;line-break:anywhere;text-align:left}.tag-modal .wrapper{z-index:9;background:#f1f1f1;border-radius:.8rem;font-size:1.4rem;padding:2rem 6rem 4rem;width:25rem}.tag-modal .wrapper input{margin-bottom:3rem;width:100%;height:3rem;outline:unset;border:1px solid #e1e1e1;padding:0 .5rem;border-radius:5px;box-sizing:border-box}.tag-modal .wrapper .btns{display:flex;justify-content:flex-end;gap:1rem}
`
let addStyle = document.createElement ("style");
addStyle.rel = "stylesheet";
addStyle.type = "text/css";
addStyle.innerHTML = style
document.head.append (addStyle)
setTimeout(function(){
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const n of o)if(n.type==="childList")for(const c of n.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function s(o){const n={};return o.integrity&&(n.integrity=o.integrity),o.referrerPolicy&&(n.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?n.credentials="include":o.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function a(o){if(o.ep)return;o.ep=!0;const n=s(o);fetch(o.href,n)}})();const l={eventMap:new Map,on(t,e){let s=this.eventMap.get(t);s?s.push(e):s=[e],this.eventMap.set(t,s)},emit(t,e){let s=this.eventMap.get(t);s&&s.map(a=>a(e))},off(t){this.eventMap.has(t)&&this.eventMap.delete(t)},clear(){this.eventMap=new Map}},i={SHOW_TOOLTIP:"SHOW_TOOLTIP",SHOW_MSG:"SHOW_MSG",SET_CALL:"SET_CALL",SHOW_CALL:"SHOW_CALL",REFRESH_ONCE:"REFRESH_ONCE",ADD_REPLY:"ADD_REPLY",IGNORE:"IGNORE",MERGE:"MERGE",REMOVE:"REMOVE",CHANGE_COMMENT_THANK:"CHANGE_COMMENT_THANK",CHANGE_POST_THANK:"CHANGE_POST_THANK",ADD_TAG:"ADD_TAG",REMOVE_TAG:"REMOVE_TAG"};const v=(t,e)=>{const s=t.__vccOpts||t;for(const[a,o]of e)s[a]=o;return s},F={name:"Point",inject:["post","isLogin"],props:{item:{type:Object,default(){return{}}},type:{type:String,default(){return"horizontal"}},apiUrl:""},computed:{disabled(){return this.item.username===window.user.username||this.item.isThanked}},methods:{getColor(t){return t?"#ff4500":"#929596"},getIsFull(t){return t?"#ff4500":"none"},async thank(){if(!this.isLogin)return l.emit(i.SHOW_MSG,{type:"warning",text:"请先登录!"});if(this.item.username===window.user.username)return l.emit(i.SHOW_MSG,{type:"warning",text:"不能感谢自己"});if(this.item.isThanked)return l.emit(i.SHOW_MSG,{type:"warning",text:"已经感谢过了"});this.$emit("addThank");let t=`${window.baseUrl}/thank/${this.apiUrl}?once=${this.post.once}`;$.post(t).then(e=>{console.log("感谢",e),e.success||(this.$emit("recallThank"),l.emit(i.SHOW_MSG,{type:"error",text:e.message})),l.emit(i.REFRESH_ONCE,e.once)},e=>{this.$emit("recallThank"),l.emit(i.SHOW_MSG,{type:"error",text:"感谢失败"}),l.emit(i.REFRESH_ONCE)})}}},j=["fill","stroke"],W={class:"num"};function U(t,e,s,a,o,n){return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["point",s.type])},[Vue.createElementVNode("div",{class:"up",onClick:e[0]||(e[0]=Vue.withModifiers((...c)=>n.thank&&n.thank(...c),["stop"]))},[(Vue.openBlock(),Vue.createElementBlock("svg",{class:Vue.normalizeClass({disabled:n.disabled}),width:"19",height:"19",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode("path",{d:"M15 8C8.92487 8 4 12.9249 4 19C4 30 17 40 24 42.3262C31 40 44 30 44 19C44 12.9249 39.0751 8 33 8C29.2797 8 25.9907 9.8469 24 12.6738C22.0093 9.8469 18.7203 8 15 8Z",fill:n.getIsFull(s.item.isThanked),stroke:n.getColor(s.item.isThanked),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,j)],2))]),Vue.createElementVNode("div",W,Vue.toDisplayString(s.item.thankCount?s.item.thankCount:"感谢"),1)],2)}const b=v(F,[["render",U],["__scopeId","data-v-42c72dce"]]);const K={name:"Author",components:{Point:b},inject:["isDev","isLogin","tags","config"],props:{modelValue:!1,comment:{type:Object,default(){return{}}}},computed:{pointInfo(){return{isThanked:this.comment.isThanked,thankCount:this.comment.thankCount,username:this.comment.username}},myTags(){return this.tags[this.comment.username]??[]}},methods:{addTag(){l.emit(i.ADD_TAG,this.comment.username)},removeTag(t){l.emit(i.REMOVE_TAG,{username:this.comment.username,tag:t})},checkIsLogin(t=""){return this.isLogin?(this.$emit(t),!0):(l.emit(i.SHOW_MSG,{type:"warning",text:"请先登录!"}),!1)},addThank(){l.emit(i.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"add"})},recallThank(){l.emit(i.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"recall"})}}},T=t=>(Vue.pushScopeId("data-v-c55a5484"),t=t(),Vue.popScopeId(),t),Z={class:"Author-left"},q=T(()=>Vue.createElementVNode("path",{d:"M22 42H6V26",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),Y=T(()=>Vue.createElementVNode("path",{d:"M26 6H42V22",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),X=[q,Y],J=["href"],Q=["src"],ee={class:"texts"},te=["href"],oe={key:0,class:"op"},ne={key:1,class:"mod"},se={class:"ago"},le={class:"my-tag"},ie=T(()=>Vue.createElementVNode("i",{class:"fa fa-tag"},null,-1)),re=["onClick"],ae={class:"Author-right"},ce={class:"toolbar"},ue=Vue.createStaticVNode('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-c55a5484><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-c55a5484></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-c55a5484></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-c55a5484></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-c55a5484></path></svg><span data-v-c55a5484>回复</span>',2),de=[ue],me=T(()=>Vue.createElementVNode("span",null,"隐藏",-1)),pe=[me];function Ve(t,e,s,a,o,n){const c=Vue.resolveComponent("Point");return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["Author",{expand:!s.modelValue}])},[Vue.createElementVNode("div",Z,[s.modelValue?Vue.createCommentVNode("",!0):(Vue.openBlock(),Vue.createElementBlock("svg",{key:0,class:"expand-icon",onClick:e[0]||(e[0]=m=>t.$emit("update:modelValue",!0)),width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},X)),Vue.createElementVNode("a",{class:"icon",href:`/member/${s.comment.username}`},[Vue.createElementVNode("img",{src:s.comment.avatar,alt:""},null,8,Q)],8,J),Vue.createElementVNode("span",ee,[Vue.createElementVNode("strong",null,[Vue.createElementVNode("a",{href:`/member/${s.comment.username}`,class:"username"},Vue.toDisplayString(s.comment.username),9,te)]),s.comment.isOp?(Vue.openBlock(),Vue.createElementBlock("div",oe,"OP")):Vue.createCommentVNode("",!0),s.comment.isMod?(Vue.openBlock(),Vue.createElementBlock("div",ne,"MOD")):Vue.createCommentVNode("",!0),Vue.createElementVNode("span",se,Vue.toDisplayString(s.comment.date),1),n.isLogin&&n.config.openTag?(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:2},[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(n.myTags,m=>(Vue.openBlock(),Vue.createElementBlock("span",le,[ie,Vue.createElementVNode("span",null,Vue.toDisplayString(m),1),Vue.createElementVNode("i",{class:"fa fa-trash-o remove",onClick:d=>n.removeTag(m)},null,8,re)]))),256)),Vue.createElementVNode("span",{class:"add-tag ago",onClick:e[1]||(e[1]=(...m)=>n.addTag&&n.addTag(...m)),title:"添加标签"},"+")],64)):Vue.createCommentVNode("",!0)])]),Vue.createElementVNode("div",ae,[Vue.createElementVNode("div",ce,[Vue.createElementVNode("div",{class:"tool",onClick:e[2]||(e[2]=m=>n.checkIsLogin("reply"))},de),Vue.createElementVNode("div",{class:"tool",onClick:e[3]||(e[3]=m=>n.checkIsLogin("hide"))},pe),s.comment.thankCount?Vue.createCommentVNode("",!0):(Vue.openBlock(),Vue.createBlock(c,{key:0,item:n.pointInfo,onAddThank:n.addThank,onRecallThank:n.recallThank,"api-url":"reply/"+s.comment.id},null,8,["item","onAddThank","onRecallThank","api-url"]))]),s.comment.thankCount?(Vue.openBlock(),Vue.createBlock(c,{key:0,item:n.pointInfo,onAddThank:n.addThank,onRecallThank:n.recallThank,"api-url":"reply/"+s.comment.id},null,8,["item","onAddThank","onRecallThank","api-url"])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{class:Vue.normalizeClass(["floor",{isDev:n.isDev}])},Vue.toDisplayString(s.comment.floor),3)])],2)}const he=v(K,[["render",Ve],["__scopeId","data-v-c55a5484"]]);const fe=t=>(Vue.pushScopeId("data-v-42e79b0b"),t=t(),Vue.popScopeId(),t),ge={class:"get-cursor"},ve=["innerHTML"],_e={class:"toolbar"},we=fe(()=>Vue.createElementVNode("span",null,"请尽量让自己的回复能够对别人有帮助",-1)),ke={__name:"PostEditor",props:{replyInfo:null,replyFloor:null,useType:{type:String,default(){return"reply-comment"}}},emits:["close"],setup(t,{emit:e}){const{replyInfo:s,replyFloor:a,useType:o,isShow:n}=t,c=Vue.inject("post");Vue.inject("allReplyUsers");let m=Vue.ref(!1);const d=Vue.ref(!1),r=Vue.ref("editorId_"+Date.now()),u=Vue.ref(s),p=Vue.ref(null),w=Vue.ref(null),C=Vue.ref('<span style="white-space:pre-wrap;"> </span>'),D=Vue.computed(()=>[o,m.value?"isFocus":""]),R=Vue.computed(()=>{var V;if(!p.value||!u.value)return"";let g=((V=p.value)==null?void 0:V.selectionStart)||0;return u.value.substring(0,g).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br/>").replace(/\s/g,C.value)}),M=Vue.computed(()=>u.value?u.value===s:!0);async function A(){if(M.value||d.value)return;d.value=!0;let g={thankCount:0,isThanked:!1,isOp:c.value.username===window.user.username,id:Date.now(),username:window.user.username,avatar:window.user.avatar,date:"几秒前",floor:c.value.replyCount+1,reply_content:u.value||Date.now(),children:[],replyUsers:[],replyFloor:a||-1},V=u.value.match(/@([\w]+?[\s])/g);V&&V.map(h=>{let f=h.replace("@","").replace(" ","");g.reply_content=g.reply_content.replace(f,`<a href="/member/${f}">${f}</a>`)});let _=`${window.baseUrl}/t/${c.value.id}`;$.post(_,{content:u.value,once:c.value.once}).then(h=>{if(d.value=!1,h.search("你上一条回复的内容和这条相同")>-1)return l.emit(i.SHOW_MSG,{type:"error",text:"你上一条回复的内容和这条相同"});if(h.search("创建新回复")>-1)return l.emit(i.REFRESH_ONCE,h),l.emit(i.SHOW_MSG,{type:"error",text:"回复失败"});u.value=s,e("close"),l.emit(i.REFRESH_ONCE,h),l.emit(i.SHOW_MSG,{type:"success",text:"回复成功"}),l.emit(i.ADD_REPLY,g)},h=>{d.value=!1,l.emit(i.SHOW_MSG,{type:"error",text:"回复失败"})})}function k(){l.emit(i.SHOW_CALL,{show:!1}),l.off(i.SET_CALL)}function y(g){let V=w.value.getBoundingClientRect();l.emit(i.SHOW_CALL,{show:!0,top:V.top,left:V.left,text:g}),l.off(i.SET_CALL),l.on(i.SET_CALL,_=>{let h=p.value.selectionStart,f=u.value.slice(0,h),B=u.value.slice(h,u.value.length),z=f.lastIndexOf("@");f=u.value.slice(0,z+1),u.value=f+_+" "+B;let I=f.length+_.length+1;setTimeout(()=>{p.value.setSelectionRange(I,I)}),l.off(i.SET_CALL)})}function P(g){switch(g.keyCode){case 8:u.value==="@"&&k();break;case 37:case 38:case 39:case 40:setTimeout(()=>L({data:""}),100);break}}function L(g){let V=p.value.selectionStart;if(u.value){if(g.data===" ")return k();if(g.data==="@"){if(u.value.length!==1){if(u.value[V-2]===" "||u.value[V-2]===`
`)return y("")}else return y("");k()}else{let _=u.value.slice(0,V),h=_.lastIndexOf("@");if(h===-1)return k();let f=_.slice(h,V);if(f.includes(" "))k();else{if(h===0)return y(f.replace("@",""));if(u.value.length!==1){if(u.value[h-1]===" "||u.value[h-1]===`
`)return y(f.replace("@",""))}else return y(f.replace("@",""));k()}}}}function G(){m.value=!1}return Vue.onMounted(()=>{$(`.${r.value}`).each(function(){this.setAttribute("style","height:"+this.scrollHeight+"px;overflow-y:hidden;")}).on("input",function(){this.style.height=0,this.style.height=this.scrollHeight+"px"}),p.value&&p.value.focus()}),Vue.onBeforeUnmount(()=>{$(`.${r.value}`).off()}),(g,V)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post-editor-wrapper",Vue.unref(D)])},[Vue.withDirectives(Vue.createElementVNode("textarea",{class:Vue.normalizeClass(["post-editor",r.value]),ref_key:"txtRef",ref:p,onFocus:V[0]||(V[0]=_=>Vue.isRef(m)?m.value=!0:m=!0),onBlur:G,onInput:L,onKeydown:P,"onUpdate:modelValue":V[1]||(V[1]=_=>u.value=_)},null,34),[[Vue.vModelText,u.value]]),Vue.createElementVNode("div",ge,[Vue.createElementVNode("span",{innerHTML:Vue.unref(R)},null,8,ve),Vue.createElementVNode("span",{class:"cursor",ref_key:"cursorRef",ref:w},"|",512)]),Vue.createElementVNode("div",_e,[we,Vue.createElementVNode("div",{class:Vue.normalizeClass(["button",{disabled:Vue.unref(M),loading:d.value}]),onClick:A},"回复 ",2)])],2))}},H=v(ke,[["__scopeId","data-v-42e79b0b"]]);const ye={key:0,class:"html-wrapper"},Ee=["innerHTML"],Ce={__name:"BaseHtmlRender",props:["html"],setup(t){const e=t,s=Vue.inject("config"),a=Vue.ref(null),o=900,n=Vue.ref(!1);function c(d){let r=window.win().getSelection().toString();if(r){let u=r.match(/([A-Za-z0-9+/=]+)/g);if(u){if(u[0].length<4)return;l.emit(i.SHOW_TOOLTIP,{text:u[0],e:d})}}}Vue.watch(s.value,d=>{d.contentAutoCollapse||(n.value=!1)}),Vue.watch([()=>a.value,()=>e.html],()=>{if(!a.value||!e.html||!s.value.contentAutoCollapse)return;let d=a.value.getBoundingClientRect();a.value.querySelectorAll("img").forEach(r=>{r.addEventListener("load",m)}),n.value=d.height>=o},{immediate:!0,flush:"post"});function m(){if(n.value)return;let d=a.value.getBoundingClientRect();n.value=d.height>=o}return(d,r)=>e.html?(Vue.openBlock(),Vue.createElementBlock("div",ye,[Vue.createElementVNode("div",{class:Vue.normalizeClass({mask:n.value})},[Vue.createElementVNode("div",Vue.mergeProps({ref_key:"contentRef",ref:a},d.$attrs,{innerHTML:e.html,onMouseup:c}),null,16,Ee)],2),n.value?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"expand",onClick:r[0]||(r[0]=u=>n.value=!1)},"展开")):Vue.createCommentVNode("",!0)])):Vue.createCommentVNode("",!0)}},O=v(Ce,[["__scopeId","data-v-ed134fcc"]]);const Ne={name:"Comment",components:{BaseHtmlRender:O,Author:he,PostEditor:H,Point:b},props:{modelValue:{reply_content:""}},data(){return{edit:!1,expand:!0,replyInfo:`@${this.modelValue.username} #${this.modelValue.floor} `,cssStyle:null}},inject:["post","postDetailWidth"],watch:{},created(){},mounted(){let t=this.$refs.comment.getBoundingClientRect(),e=this.postDetailWidth/2;if(e<t.width&&t.width<e+25&&this.modelValue.children.length){this.expand=!1;let s=2;this.cssStyle={padding:"1rem 0",width:`calc(${this.postDetailWidth}px - ${s}rem)`,transform:`translateX(calc(${t.width-this.postDetailWidth}px + ${s}rem))`}}},methods:{hide(){let t=`${window.baseUrl}/ignore/reply/${this.modelValue.id}?once=${this.post.once}`;l.emit(i.REMOVE,this.modelValue.floor),$.post(t).then(e=>{l.emit(i.REFRESH_ONCE),l.emit(i.SHOW_MSG,{type:"success",text:"隐藏成功"})},e=>{l.emit(i.SHOW_MSG,{type:"warning",text:"隐藏成功,仅本次有效(接口调用失败!)"})})},toggle(){this.expand=!this.expand}}},Te={class:"comment-content"},xe={class:"right"},Se={class:"w"};function Be(t,e,s,a,o,n){const c=Vue.resolveComponent("Author"),m=Vue.resolveComponent("BaseHtmlRender"),d=Vue.resolveComponent("PostEditor"),r=Vue.resolveComponent("Comment",!0);return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["comment",s.modelValue.isOp?"op":""]),ref:"comment"},[Vue.createVNode(c,{modelValue:o.expand,"onUpdate:modelValue":e[0]||(e[0]=u=>o.expand=u),comment:s.modelValue,onReply:e[1]||(e[1]=u=>o.edit=!o.edit),onHide:n.hide},null,8,["modelValue","comment","onHide"]),o.cssStyle&&!o.expand?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"more ago",onClick:e[2]||(e[2]=u=>o.expand=!o.expand)}," 由于嵌套回复层级太深,自动将后续回复隐藏 ")):Vue.createCommentVNode("",!0),Vue.withDirectives(Vue.createElementVNode("div",{class:"comment-content-w",style:Vue.normalizeStyle(o.cssStyle)},[o.cssStyle?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"more ago",onClick:e[3]||(e[3]=u=>o.expand=!o.expand)}," 由于嵌套回复层级太深,自动将以下回复移至可见范围 ")):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",Te,[Vue.createElementVNode("div",{class:"left expand-line",onClick:e[4]||(e[4]=(...u)=>n.toggle&&n.toggle(...u))}),Vue.createElementVNode("div",xe,[Vue.createElementVNode("div",Se,[Vue.createVNode(m,{class:"text",html:s.modelValue.reply_content},null,8,["html"]),o.edit?(Vue.openBlock(),Vue.createBlock(d,{key:0,onClose:e[5]||(e[5]=u=>o.edit=!1),replyInfo:o.replyInfo,replyFloor:s.modelValue.floor},null,8,["replyInfo","replyFloor"])):Vue.createCommentVNode("",!0)]),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(s.modelValue.children,(u,p)=>(Vue.openBlock(),Vue.createBlock(r,{modelValue:s.modelValue.children[p],"onUpdate:modelValue":w=>s.modelValue.children[p]=w,key:p},null,8,["modelValue","onUpdate:modelValue"]))),128))])]),o.cssStyle?(Vue.openBlock(),Vue.createElementBlock("div",{key:1,class:"more ago",onClick:e[6]||(e[6]=u=>o.expand=!o.expand)}," 由于嵌套回复层级太深,自动将以上回复移至可见范围 ")):Vue.createCommentVNode("",!0)],4),[[Vue.vShow,o.expand]])],2)}const be=v(Ne,[["render",Be],["__scopeId","data-v-6a750f0d"]]);const Me={name:"Toolbar",inject:["isLogin","post","pageType"],data(){return{timer:null,showTooltip:!1,loading:!1,loading2:!1,loading3:!1}},methods:{checkIsLogin(t=""){return this.isLogin?(this.$emit(t),!0):(l.emit(i.SHOW_MSG,{type:"warning",text:"请先登录!"}),!1)},getColor(t){return t?"#ff4500":"#929596"},getIsFull(t){return t?"#ff4500":"none"},showTooltipHandler(){this.timer&&clearTimeout(this.timer),this.showTooltip=!0},hideTooltip(){this.timer=setTimeout(()=>{this.showTooltip=!1},500)},tweet(){if(!this.checkIsLogin())return;let t=window.user.username,e=`https://twitter.com/share?url=${window.baseUrl}/t/${this.post.id}?r=${t}&related=v2ex&hashtags=apple&text=${this.post.title}`;window.win().open(e,"_blank","width=550,height=370")},report(){if(!this.checkIsLogin()||!this.isLogin||this.post.isReport)return;let t=window.user.username,e=`https://twitter.com/share?url=${window.baseUrl}/t/${this.post.id}?r=${t}&related=v2ex&hashtags=apple&text=${this.post.title}`;window.win().open(e,"_blank","width=550,height=370")},async toggleIgnore(){if(!this.checkIsLogin())return;let t=`${window.baseUrl}/${this.post.isIgnore?"unignore":"ignore"}/topic/${this.post.id}?once=${this.post.once}`;this.pageType==="post"?(this.loading2=!0,(await window.win().fetch(t)).redirected?(this.post.isIgnore||(window.win().location=window.baseUrl),l.emit(i.SHOW_MSG,{type:"success",text:this.post.isIgnore?"取消成功":"忽略成功"}),l.emit(i.MERGE,{isIgnore:!this.post.isIgnore})):l.emit(i.SHOW_MSG,{type:"warning",text:"忽略失败"}),this.loading2=!1):(this.post.isIgnore?this.loading2=!0:l.emit(i.IGNORE),(await window.win().fetch(t)).redirected?(this.post.isIgnore&&l.emit(i.REFRESH_ONCE),l.emit(i.SHOW_MSG,{type:"success",text:this.post.isIgnore?"取消成功":"忽略成功"}),l.emit(i.MERGE,{isIgnore:!this.post.isIgnore})):l.emit(i.SHOW_MSG,{type:"warning",text:"忽略成功,仅本次有效(接口调用失败!)"}),this.loading2=!1)},async toggleFavorite(){if(!this.checkIsLogin())return;this.loading=!0;let t=`${window.baseUrl}/${this.post.isFavorite?"unfavorite":"favorite"}/topic/${this.post.id}?once=${this.post.once}`,e=await window.win().fetch(t);if(this.loading=!1,e.redirected){let s=await e.text();if(s.search(this.post.isFavorite?"加入收藏":"取消收藏")){l.emit(i.MERGE,{collectCount:this.post.isFavorite?this.post.collectCount-1:this.post.collectCount+1}),l.emit(i.SHOW_MSG,{type:"success",text:this.post.isFavorite?"取消成功":"收藏成功"}),l.emit(i.REFRESH_ONCE,s),l.emit(i.MERGE,{isFavorite:!this.post.isFavorite});return}}l.emit(i.SHOW_MSG,{type:"error",text:"操作失败"})}}},E=t=>(Vue.pushScopeId("data-v-1f833fb4"),t=t(),Vue.popScopeId(),t),Le={class:"toolbar"},Ie=Vue.createStaticVNode('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-1f833fb4><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-1f833fb4></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-1f833fb4></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-1f833fb4></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-1f833fb4></path></svg><span data-v-1f833fb4>回复</span>',2),He=[Ie],Oe={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},De=["fill","stroke"],Re={key:1,class:"tool no-hover"},Ae=E(()=>Vue.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode("path",{d:"M28 6H42V20",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M42 29.4737V39C42 40.6569 40.6569 42 39 42H9C7.34315 42 6 40.6569 6 39V9C6 7.34315 7.34315 6 9 6L18 6",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M25.7998 22.1999L41.0998 6.8999",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),Pe=E(()=>Vue.createElementVNode("span",null,"Tweet",-1)),Ge=[Ae,Pe],ze={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Fe=["fill","stroke"],je=["fill","stroke"],We=["fill","stroke"],Ue=Vue.createStaticVNode('<svg width="19" height="19" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-1f833fb4><path d="M36 35H12V21C12 14.3726 17.3726 9 24 9C30.6274 9 36 14.3726 36 21V35Z" fill="#929596" stroke="#929596" stroke-width="4" stroke-linejoin="round" data-v-1f833fb4></path><path d="M8 42H40" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-1f833fb4></path><path d="M4 13L7 14" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-1f833fb4></path><path d="M13 3.9999L14 6.9999" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-1f833fb4></path><path d="M10.0001 9.99989L7.00009 6.99989" stroke="#929596" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" data-v-1f833fb4></path></svg>',1),$e=E(()=>Vue.createElementVNode("a",{target:"_blank",href:"https://github.com/zyronon/v2ex-script/issues"},"点击这里提一个Issue",-1)),Ke=E(()=>Vue.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode("path",{d:"M8 44H12H16",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M12 44V4",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M40 6H12V22H40L36 14L40 6Z",fill:"none",stroke:"#929596","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),Ze=E(()=>Vue.createElementVNode("span",null,"脚本有问题?",-1));function qe(t,e,s,a,o,n){return Vue.openBlock(),Vue.createElementBlock("div",Le,[Vue.createElementVNode("div",{class:"tool",onClick:e[0]||(e[0]=c=>n.checkIsLogin("reply"))},He),n.post.once?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:Vue.normalizeClass(["tool",{loading:o.loading}]),onClick:e[1]||(e[1]=(...c)=>n.toggleFavorite&&n.toggleFavorite(...c))},[(Vue.openBlock(),Vue.createElementBlock("svg",Oe,[Vue.createElementVNode("path",{d:"M23.9986 5L17.8856 17.4776L4 19.4911L14.0589 29.3251L11.6544 43L23.9986 36.4192L36.3454 43L33.9586 29.3251L44 19.4911L30.1913 17.4776L23.9986 5Z",fill:n.getIsFull(n.post.isFavorite),stroke:n.getColor(n.post.isFavorite),"stroke-width":"2","stroke-linejoin":"round"},null,8,De)])),Vue.createElementVNode("span",null,Vue.toDisplayString(n.post.isFavorite?"取消收藏":"加入收藏"),1)],2)):Vue.createCommentVNode("",!0),n.post.once&&n.post.collectCount!==0?(Vue.openBlock(),Vue.createElementBlock("div",Re,[Vue.createElementVNode("span",null,Vue.toDisplayString(n.post.collectCount+"人收藏"),1)])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{class:"tool",onClick:e[2]||(e[2]=(...c)=>n.tweet&&n.tweet(...c))},Ge),n.post.once?(Vue.openBlock(),Vue.createElementBlock("div",{key:2,class:Vue.normalizeClass(["tool",{loading:o.loading2}]),onClick:e[3]||(e[3]=(...c)=>n.toggleIgnore&&n.toggleIgnore(...c))},[(Vue.openBlock(),Vue.createElementBlock("svg",ze,[Vue.createElementVNode("path",{fill:n.getIsFull(n.post.isIgnore),stroke:n.getColor(n.post.isIgnore),d:"M9.85786 18C6.23858 21 4 24 4 24C4 24 12.9543 36 24 36C25.3699 36 26.7076 35.8154 28 35.4921M20.0318 12.5C21.3144 12.1816 22.6414 12 24 12C35.0457 12 44 24 44 24C44 24 41.7614 27 38.1421 30","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Fe),Vue.createElementVNode("path",{fill:n.getIsFull(n.post.isIgnore),d:"M20.3142 20.6211C19.4981 21.5109 19 22.6972 19 23.9998C19 26.7612 21.2386 28.9998 24 28.9998C25.3627 28.9998 26.5981 28.4546 27.5 27.5705",stroke:n.getColor(n.post.isIgnore),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,je),Vue.createElementVNode("path",{d:"M42 42L6 6",fill:n.getIsFull(n.post.isIgnore),stroke:n.getColor(n.post.isIgnore),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,8,We)])),Vue.createElementVNode("span",null,Vue.toDisplayString(n.post.isIgnore?"取消忽略":"忽略主题"),1)],2)):Vue.createCommentVNode("",!0),n.post.once&&n.post.isLogin?(Vue.openBlock(),Vue.createElementBlock("div",{key:3,class:Vue.normalizeClass(["tool",{loading:o.loading3,"no-hover":n.post.isLogin}]),onClick:e[4]||(e[4]=(...c)=>n.report&&n.report(...c))},[Ue,Vue.createElementVNode("span",null,Vue.toDisplayString(n.post.isReport?"你已对本主题进行了报告":"报告这个主题"),1)],2)):Vue.createCommentVNode("",!0),n.post.once?(Vue.openBlock(),Vue.createElementBlock("div",{key:4,class:"tool no-hover",onMouseenter:e[7]||(e[7]=(...c)=>n.showTooltipHandler&&n.showTooltipHandler(...c)),onMouseleave:e[8]||(e[8]=(...c)=>n.hideTooltip&&n.hideTooltip(...c))},[o.showTooltip?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"tooltip",onMouseenter:e[5]||(e[5]=(...c)=>n.showTooltipHandler&&n.showTooltipHandler(...c)),onMouseleave:e[6]||(e[6]=(...c)=>n.hideTooltip&&n.hideTooltip(...c))},[Vue.createTextVNode(" 脚本有问题?"),$e],32)):Vue.createCommentVNode("",!0),Ke,Ze],32)):Vue.createCommentVNode("",!0)])}const Ye=v(Me,[["render",qe],["__scopeId","data-v-1f833fb4"]]);const Xe={name:"detail",components:{Comment:be,PostEditor:H,Point:b,Toolbar:Ye,BaseHtmlRender:O},inject:["allReplyUsers","post","isLogin","config"],provide(){return{postDetailWidth:Vue.computed(()=>{var t;return((t=this.$refs.comments)==null?void 0:t.getBoundingClientRect().width)||0})}},props:{modelValue:{type:Boolean,default(){return!1}},loading:{type:Boolean,default(){return!1}},isNight:{type:Boolean,default(){return!1}},displayType:0},data(){return{isSticky:!1,selectCallIndex:0,postDetailWidth:0,showCallList:!1,replyText:"",callStyle:{top:0,left:0}}},computed:{filterCallList(){return this.showCallList?this.replyText?this.allReplyUsers.filter(t=>t.search(this.replyText)>-1):this.allReplyUsers:[]},replies(){return this.displayType===0?this.post.nestedReplies:this.displayType===1?window.clone(this.post.nestedReplies).sort((t,e)=>e.thankCount-t.thankCount):this.displayType===2?this.post.replies:[]}},watch:{modelValue:{handler(t){t?(window.win().doc.body.style.overflow="hidden",this.$nextTick(()=>{this.$refs.main.focus(),this.$refs.detail.scrollTo({top:0})})):(window.win().doc.body.style.overflow="unset",this.isSticky=!1,(window.pageType==="home"||window.pageType==="nodePage")&&window.history.back())}}},mounted(){this.isLogin&&(new IntersectionObserver(([e])=>e.target.toggleAttribute("stuck",e.intersectionRatio<1),{threshold:[1]}).observe(this.$refs.replyBox),window.win().addEventListener("keydown",this.onKeyDown)),l.on(i.SHOW_CALL,t=>{t.show?(this.showCallList=!0,this.replyText=t.text,this.callStyle.top=t.top+$(".post-detail").scrollTop()+15+"px",this.callStyle.left=t.left-$(".main")[0].getBoundingClientRect().left+10+"px",this.selectCallIndex>=this.filterCallList.length&&(this.selectCallIndex=0)):(this.replyText="",this.showCallList=!1,this.selectCallIndex=0)})},beforeUnmount(){this.$refs.right.innerHTML="",window.win().removeEventListener("keydown",this.onKeyDown),l.off(i.SHOW_CALL)},methods:{close(t){t==="space"?this.config.closePostDetailBySpace&&this.$emit("update:modelValue",!1):this.$emit("update:modelValue",!1)},setCall(t){l.emit(i.SET_CALL,t),this.showCallList=!1},onKeyDown(t){if(!this.modelValue||!this.showCallList)return;let e=this.filterCallList.slice(0,10).length;t.keyCode===13&&(this.setCall(this.filterCallList[this.selectCallIndex]),t.preventDefault()),t.keyCode===38&&(this.selectCallIndex--,this.selectCallIndex<0&&(this.selectCallIndex=e-1),t.preventDefault()),t.keyCode===40&&(this.selectCallIndex++,this.selectCallIndex>e-1&&(this.selectCallIndex=0),t.preventDefault())},changeOption(t){this.$emit("update:displayType",t)},addThank(){l.emit(i.CHANGE_POST_THANK,{id:this.post.id,type:"add"})},recallThank(){l.emit(i.CHANGE_POST_THANK,{id:this.post.id,type:"recall"})},scrollTop(){this.$refs.detail.scrollTo({top:0,behavior:"smooth"})}}},x=t=>(Vue.pushScopeId("data-v-b3448560"),t=t(),Vue.popScopeId(),t),Je={class:"main-wrapper"},Qe={class:"my-box post-wrapper"},et={class:"toolbar-wrapper"},tt={key:0,class:"my-box comment-wrapper"},ot={key:0,class:"my-cell flex flex-end"},nt={class:"radio-group2"},st={class:"my-cell flex"},lt={class:"gray"},it={key:0},rt=x(()=>Vue.createElementVNode("strong",{class:"snow"},"•",-1)),at=["innerHTML"],ct={key:1,class:"loading-wrapper"},ut={key:2,class:"comments",ref:"comments"},dt={key:1,id:"no-comments-yet"},mt={class:"my-cell flex"},pt=x(()=>Vue.createElementVNode("span",null,"添加一条新回复",-1)),Vt={class:"notice-right"},ht={class:"w"},ft=["onClick"],gt=x(()=>Vue.createElementVNode("i",{class:"fa fa-times","aria-hidden":"true"},null,-1)),vt=[gt],_t=x(()=>Vue.createElementVNode("i",{class:"fa fa-long-arrow-up","aria-hidden":"true"},null,-1)),wt=[_t];function kt(t,e,s,a,o,n){const c=Vue.resolveComponent("BaseHtmlRender"),m=Vue.resolveComponent("Point"),d=Vue.resolveComponent("Toolbar"),r=Vue.resolveComponent("Comment"),u=Vue.resolveComponent("PostEditor");return Vue.withDirectives((Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post-detail",[s.isNight?"isNight":""]]),ref:"detail",onKeydown:e[10]||(e[10]=Vue.withKeys(p=>n.close(),["esc"])),onClick:e[11]||(e[11]=p=>n.close("space"))},[Vue.createElementVNode("div",{ref:"main",class:"main",tabindex:"1",onClick:e[9]||(e[9]=Vue.withModifiers(()=>{},["stop"]))},[Vue.createElementVNode("div",Je,[Vue.createElementVNode("div",Qe,[Vue.createVNode(c,{html:n.post.headerTemplate},null,8,["html"]),Vue.createElementVNode("div",et,[Vue.createVNode(m,{onAddThank:n.addThank,onRecallThank:n.recallThank,item:{isThanked:n.post.isThanked,thankCount:n.post.thankCount,username:n.post.username},"api-url":"topic/"+n.post.id},null,8,["onAddThank","onRecallThank","item","api-url"]),Vue.createVNode(d,{onReply:e[0]||(e[0]=p=>o.isSticky=!o.isSticky)})])]),n.replies.length||s.loading?(Vue.openBlock(),Vue.createElementBlock("div",tt,[n.config.showToolbar?(Vue.openBlock(),Vue.createElementBlock("div",ot,[Vue.createElementVNode("div",nt,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===0?"active":""]),onClick:e[1]||(e[1]=p=>n.changeOption(0))},"楼中楼 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===1?"active":""]),onClick:e[2]||(e[2]=p=>n.changeOption(1))},"感谢 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===2?"active":""]),onClick:e[3]||(e[3]=p=>n.changeOption(2))},"V2原版 ",2)])])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",st,[Vue.createElementVNode("span",lt,[Vue.createTextVNode(Vue.toDisplayString(n.post.replyCount)+" 条回复 ",1),n.post.createDate?(Vue.openBlock(),Vue.createElementBlock("span",it,[Vue.createTextVNode(" "),rt,Vue.createTextVNode(" "+Vue.toDisplayString(n.post.createDate),1)])):Vue.createCommentVNode("",!0)]),Vue.createElementVNode("div",{class:"fr",innerHTML:n.post.fr},null,8,at)]),s.loading?(Vue.openBlock(),Vue.createElementBlock("div",ct,[Vue.createElementVNode("div",{class:Vue.normalizeClass([s.isNight?"loading-b":"loading-c"])},null,2)])):(Vue.openBlock(),Vue.createElementBlock("div",ut,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(n.replies,(p,w)=>(Vue.openBlock(),Vue.createBlock(r,{key:p.floor,style:Vue.normalizeStyle(`border-bottom: 1px solid ${s.isNight?"#22303f":"#f2f2f2"}; padding: 1rem;margin-top: 0;`),modelValue:n.replies[w],"onUpdate:modelValue":C=>n.replies[w]=C},null,8,["style","modelValue","onUpdate:modelValue"]))),128))],512))])):(Vue.openBlock(),Vue.createElementBlock("div",dt,"目前尚无回复")),n.isLogin?(Vue.openBlock(),Vue.createElementBlock("div",{key:2,class:Vue.normalizeClass(["my-box editor-wrapper",{sticky:o.isSticky}]),ref:"replyBox"},[Vue.createElementVNode("div",mt,[pt,Vue.createElementVNode("div",Vt,[o.isSticky?(Vue.openBlock(),Vue.createElementBlock("a",{key:0,class:"float",onClick:e[4]||(e[4]=p=>o.isSticky=!1)},"取消回复框停靠")):Vue.createCommentVNode("",!0),Vue.createElementVNode("a",{onClick:e[5]||(e[5]=(...p)=>n.scrollTop&&n.scrollTop(...p))},"回到顶部")])]),Vue.createElementVNode("div",ht,[Vue.createVNode(u,{useType:"reply-post",onClick:e[6]||(e[6]=p=>o.isSticky=!0)})])],2)):Vue.createCommentVNode("",!0)]),o.showCallList&&n.filterCallList.length?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"call-list",style:Vue.normalizeStyle(o.callStyle)},[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(n.filterCallList.slice(0,10),(p,w)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["call-item",{select:w===o.selectCallIndex}]),onClick:C=>n.setCall(p)},[Vue.createElementVNode("a",null,Vue.toDisplayString(p),1)],10,ft))),256))],4)):Vue.createCommentVNode("",!0),n.config.closePostDetailBySpace?(Vue.openBlock(),Vue.createElementBlock("div",{key:1,class:"close-btn",onClick:e[7]||(e[7]=p=>n.close("btn"))},vt)):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{class:"scroll-top button gray",onClick:e[8]||(e[8]=Vue.withModifiers((...p)=>n.scrollTop&&n.scrollTop(...p),["stop"]))},wt)],512)],34)),[[Vue.vShow,s.modelValue]])}const yt=v(Xe,[["render",kt],["__scopeId","data-v-b3448560"]]);const Et={class:"base-info"},Ct={class:"left"},Nt=["onClick","href"],Tt={class:"avatar"},xt=["src"],St={class:"right"},Bt={class:"title"},bt=["href"],Mt={class:"bottom"},Lt=["onClick","href"],It=["onClick","href"],Ht={class:"date"},Ot={key:0,class:"count"},Dt=["innerHTML"],Rt={__name:"Post",props:["post","viewType","isNight"],setup(t){const e=t,s=200,a=Vue.ref(!1),o=Vue.ref(null),n=Vue.computed(()=>e.post.bg?{backgroundImage:e.post.bg,backgroundRepeat:"no-repeat",backgroundSize:"20px 20px",backgroundPosition:"right top"}:{});Vue.watch([()=>e.post,()=>o.value,()=>e.viewType],()=>{if(!o.value||e.viewType==="table")return;let m=o.value.getBoundingClientRect();o.value.querySelectorAll("img").forEach(d=>{d.addEventListener("load",c)}),a.value=m.height>=s},{immediate:!0,flush:"post"});function c(){if(a.value)return;let m=o.value.getBoundingClientRect();a.value=m.height>=s}return(m,d)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post",[e.viewType,e.isNight?"isNight":""]]),style:Vue.normalizeStyle(Vue.unref(n)),onClick:d[0]||(d[0]=r=>m.$emit("show",r))},[Vue.createElementVNode("div",Et,[Vue.createElementVNode("div",Ct,[Vue.createElementVNode("a",{onClick:Vue.withModifiers(r=>null,["stop"]),href:`/member/${e.post.username}`},[Vue.createElementVNode("div",Tt,[Vue.createElementVNode("img",{src:e.post.avatar,alt:""},null,8,xt)])],8,Nt),Vue.createElementVNode("div",St,[Vue.createElementVNode("div",Bt,[Vue.createElementVNode("a",{href:`t/${e.post.id}`},Vue.toDisplayString(e.post.title),9,bt)]),Vue.createElementVNode("div",Mt,[e.post.node?(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:0},[Vue.createElementVNode("a",{onClick:Vue.withModifiers(r=>null,["stop"]),href:e.post.nodeUrl,class:"my-node"},Vue.toDisplayString(e.post.node),9,Lt),Vue.createTextVNode(" • ")],64)):Vue.createCommentVNode("",!0),Vue.createElementVNode("strong",null,[Vue.createElementVNode("a",{onClick:Vue.withModifiers(r=>null,["stop"]),class:"username",href:`/member/${e.post.username}`},Vue.toDisplayString(e.post.username),9,It)]),Vue.createTextVNode(" • "),Vue.createElementVNode("span",Ht,Vue.toDisplayString(e.post.date),1)])])]),e.post.replyCount?(Vue.openBlock(),Vue.createElementBlock("div",Ot,Vue.toDisplayString(e.post.replyCount),1)):Vue.createCommentVNode("",!0)]),e.post.content_rendered?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:Vue.normalizeClass(["post-content-wrapper",{mask:a.value}])},[Vue.createElementVNode("div",{innerHTML:e.post.content_rendered,ref_key:"contentRef",ref:o},null,8,Dt)],2)):Vue.createCommentVNode("",!0)],6))}},At=v(Rt,[["__scopeId","data-v-71df4ceb"]]),Pt={name:"Msg",props:{type:"",text:""},created(){setTimeout(()=>{this.$emit("close")},3e3)}},Gt=Vue.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode("path",{d:"M14 14L34 34",stroke:"#ffffff","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M14 34L34 14",stroke:"#ffffff","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"})],-1),zt=[Gt],Ft={class:"right"};function jt(t,e,s,a,o,n){return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["msg",s.type])},[Vue.createElementVNode("div",{class:"left",onClick:e[0]||(e[0]=c=>t.$emit("close"))},zt),Vue.createElementVNode("div",Ft,Vue.toDisplayString(s.text),1)],2)}const Wt=v(Pt,[["render",jt]]);const Ut=t=>(Vue.pushScopeId("data-v-2d42a498"),t=t(),Vue.popScopeId(),t),$t=Ut(()=>Vue.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[Vue.createElementVNode("path",{d:"M17 32L19.1875 27M31 32L28.8125 27M19.1875 27L24 16L28.8125 27M19.1875 27H28.8125",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M43.1999 20C41.3468 10.871 33.2758 4 23.5999 4C13.9241 4 5.85308 10.871 4 20L10 18",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"}),Vue.createElementVNode("path",{d:"M4 28C5.85308 37.129 13.9241 44 23.5999 44C33.2758 44 41.3468 37.129 43.1999 28L38 30",stroke:"#929596","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),Kt={key:1},Zt={__name:"Base64Tooltip",setup(t){const e=Vue.ref(null),s=Vue.ref(!1),a=Vue.ref(""),o=Vue.ref(""),n=Vue.reactive({left:"-100vw",top:"-100vh"});Vue.onMounted(()=>{l.on(i.SHOW_TOOLTIP,({text:r,e:u})=>{setTimeout(()=>s.value=!0),a.value=r,o.value="",n.left=u.clientX+"px",n.top=u.clientY+20+"px"}),window.win().addEventListener("click",r=>{e.value&&!e.value.contains(r.target)&&s.value&&(s.value=!1)},{capture:!0});const d=()=>s.value&&(s.value=!1);$(".post-detail",window.win().doc).on("scroll",d)});function c(){window.win().navigator.clipboard?(window.win().navigator.clipboard.writeText(o.value),l.emit(i.SHOW_MSG,{type:"success",text:"复制成功"})):l.emit(i.SHOW_MSG,{type:"error",text:"复制失败!浏览器不支持!"})}function m(){try{o.value=window.atob(a.value)}catch{l.emit(i.SHOW_MSG,{type:"error",text:"Base64解码失败!不是标准数据!"})}}return(d,r)=>Vue.withDirectives((Vue.openBlock(),Vue.createElementBlock("div",{class:"base64_tooltip",style:Vue.normalizeStyle(n),onClick:m,ref_key:"tooltip",ref:e},[o.value?(Vue.openBlock(),Vue.createElementBlock("div",Kt,[Vue.createElementVNode("span",null,Vue.toDisplayString(o.value),1),Vue.createElementVNode("div",{class:"button",onClick:c},"点击复制")])):(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:0},[Vue.createTextVNode(" Base64解码:"+Vue.toDisplayString(a.value)+" ",1),$t],64))],4)),[[Vue.vShow,s.value]])}},qt=v(Zt,[["__scopeId","data-v-2d42a498"]]);const Yt={name:"home",provide(){return{isDev:Vue.computed(()=>!1),isLogin:Vue.computed(()=>!!window.user.username),pageType:Vue.computed(()=>this.pageType),tags:Vue.computed(()=>this.tags),post:Vue.computed(()=>this.current),config:Vue.computed(()=>this.config),allReplyUsers:Vue.computed(()=>Array.from(new Set(this.current.replies.map(t=>t.username))))}},components:{PostDetail:yt,Post:At,Msg:Wt,Base64Tooltip:qt},data(){return{loading:window.pageType==="post",loadMore:!1,pageType:window.pageType,isNight:window.isNight,msgList:[],show:!1,showConfig:!1,current:window.initPost,list:[],config:window.config,tags:window.user.tags,tagModal:{show:!1,currentUsername:"",tag:""}}},computed:{isDev(){return!1},isList(){return this.pageType==="home"||this.pageType==="recent"||this.pageType==="nodePage"}},watch:{"current.replies":{handler(t,e){if(t.length){this.current.replyCount=t.length;let s=window.parse.createNestedList(t,this.current.allReplyUsers);s&&(this.current.nestedReplies=s)}else this.current.replyCount=0,this.current.nestedReplies=[];if(this.list){let s=this.list.findIndex(a=>a.id===this.current.id);s>-1&&(this.list[s].replyCount=t.length)}},deep:!0},config:{handler(t){let e={[window.user.username??"default"]:t};window.win().localStorage.setItem("v2ex-config",JSON.stringify(e)),window.config=t},deep:!0},tags(t){window.user.tags=t},"config.viewType"(t){t&&(t==="card"?$(".post-item").each(function(){$(this).addClass("preview")}):$(".post-item").each(function(){$(this).removeClass("preview")}))}},created(){window.cb=this.winCb,this.config.autoOpenDetail&&this.pageType==="post"&&(this.loading=!0,window.win().doc.body.style.overflow="hidden",this.show=!0),window.win().canParseV2exPage&&this.isList,$(window.win().doc).on("click","a",t=>{let{href:e,id:s}=window.parse.parseA(t.currentTarget);if(s&&this.config.clickPostItemOpenDetail){let a=this.list.findIndex(o=>o.id==s);if(a>-1){let o=this.list[a],n=`
<div class="header">
<div class="fr">
<a href="/member/${o.member.username}">
<img src="${o.member.avatar_large}" class="avatar"
border="0"
align="default" width="73" style="width: 73px; max-height: 73px;" alt="${o.member.username}">
</a>
</div>
<a href="/">V2EX</a> <span class="chevron"> › </span> <a href="${o.node.url}">${o.node.title}</a>
<div class="sep10"></div>
<h1>${o.title}</h1>
<div id="topic_930514_votes" class="votes">
<a href="javascript:" onclick="null" class="vote">
<li class="fa fa-chevron-up"></li>
</a>
<a href="javascript:" onclick="null" class="vote">
<li class="fa fa-chevron-down"></li>
</a>
</div>
<small class="gray">
<a href="/member/zyronon">${o.member.username}</a> ·
<span title="2023-04-07 11:32:28 +08:00">1 天前</span> · 3334 次点击
</small>
</div>
<div class="cell">
<div class="topic_content">
<div class="markdown_body">
${o.content_rendered}
</div>
</div>
</div>
`;return o.headerTemplate=n,this.getPostDetail(o),t.preventDefault(),!1}}}),$(window.win().doc).on("click",".toggle",t=>{let e=t.currentTarget.dataset.id,s=window.win().query(`.id_${e}`);s.classList.contains("preview")?s.classList.remove("preview"):s.classList.add("preview")}),this.initEvent()},beforeUnmount(){l.clear()},methods:{async addTag(){let t=this.clone(this.tags),e=this.tags[this.tagModal.currentUsername]??[];if(e.findIndex(o=>o===this.tagModal.tag)>-1){l.emit(i.SHOW_MSG,{type:"warning",text:"标签已存在!"});return}else e.push(this.tagModal.tag);this.tags[this.tagModal.currentUsername]=e,this.tagModal.tag="",this.tagModal.show=!1;let a=await window.parse.saveTags(this.tags);return a||(l.emit(i.SHOW_MSG,{type:"error",text:"标签添加失败!"}),this.tags=t),console.log("res",a),console.log(this.tags)},async winCb({type:t,value:e}){t==="openSetting"&&(this.showConfig=!0),t==="postContent"&&(this.current=Object.assign(this.clone(window.initPost),this.clone(e))),t==="postReplies"&&(this.current=Object.assign(this.current,this.clone(e)),this.loading=!1),t==="syncData"&&(this.list=window.postList,this.config=window.config,this.tags=window.user.tags)},clone(t){return window.clone(t)},initEvent(){l.on(i.CHANGE_COMMENT_THANK,t=>{const{id:e,type:s}=t;let a=this.current.replies.findIndex(o=>o.id===e);a>-1&&(this.current.replies[a].isThanked=s==="add",s==="add"?this.current.replies[a].thankCount++:this.current.replies[a].thankCount--)}),l.on(i.CHANGE_POST_THANK,t=>{const{id:e,type:s}=t;this.current.isThanked=s==="add",s==="add"?this.current.thankCount++:this.current.thankCount--;let a=this.list.findIndex(o=>o.id===e);a>-1&&(this.list[a].isThanked=s==="add",s==="add"?this.list[a].thankCount++:this.list[a].thankCount++)}),l.on(i.REMOVE,t=>{let e=this.current.replies.findIndex(a=>a.floor===t);e>-1&&this.current.replies.splice(e,1);let s=this.list.findIndex(a=>a.id===this.current.id);s>-1&&(this.list[s]=Object.assign(this.list[s],t))}),l.on(i.SHOW_MSG,t=>{this.msgList.push({...t,id:Date.now()})}),l.on(i.IGNORE,()=>{this.show=!1;let t=this.list.findIndex(e=>e.id===this.current.id);t>-1&&this.list.splice(t,1),this.current=this.clone(window.initPost)}),l.on(i.MERGE,t=>{this.current=Object.assign(this.current,t);let e=this.list.findIndex(s=>s.id===this.current.id);e>-1&&(this.list[e]=Object.assign(this.list[e],t))}),l.on(i.ADD_REPLY,t=>{this.current.replies.push(t)}),l.on(i.REFRESH_ONCE,async t=>{if(t){if(typeof t=="string"){let e=t.match(/var once = "([\d]+)";/);if(e&&e[1]){this.current.once=Number(e[1]);return}}if(typeof t=="number"){this.current.once=t;return}}window.win().fetchOnce().then(e=>{this.current.once=e})}),l.on(i.ADD_TAG,t=>{console.log("use",t),this.tagModal.currentUsername=t,this.tagModal.show=!0}),l.on(i.REMOVE_TAG,async({username:t,tag:e})=>{let s=this.clone(this.tags),a=this.tags[t]??[],o=a.findIndex(c=>c===e);o>-1&&a.splice(o,1),this.tags[t]=a,await window.parse.saveTags(this.tags)||(l.emit(i.SHOW_MSG,{type:"error",text:"标签删除失败!"}),this.tags=s)})},removeMsg(t){let e=this.msgList.findIndex(s=>s.id===t);e>-1&&this.msgList.splice(e,1)},async getPostDetail(t,e){this.show=!0,console.log("window.baseUrl",window.baseUrl);let s=window.baseUrl+"/t/"+t.id;window.win().doc.body.style.overflow="hidden",window.win().history.pushState({},0,t.href??s),this.current=Object.assign(this.clone(window.initPost),this.clone(t)),this.current.replies.length||(this.loading=!0);let a=await window.win().fetch(s+"?p=1");if(a.status===404)return l.emit(i.SHOW_MSG,{type:"error",text:"主题未找到"}),this.loading=!1;if(a.redirected)return l.emit(i.SHOW_MSG,{type:"error",text:"没有权限"}),this.loading=!1;let o=await a.text();if(o.search("你要查看的页面需要先登录")>-1)return l.emit(i.SHOW_MSG,{type:"error",text:"你要查看的页面需要先登录"}),this.loading=!1;let c=o.match(/<body[^>]*>([\s\S]+?)<\/body>/g),m=$(c[0]);if(this.current=await window.parse.getPostDetail(this.current,m,o),this.current.replies.length){let d=this.list.findIndex(r=>r.id==t.id);d>-1&&(this.list[d].replies=this.current.replies,this.list[d].nestedReplies=this.current.nestedReplies,this.list[d].once=this.current.once,this.list[d].createDate=this.current.createDate)}this.loading=!1,console.log("当前帖子",this.current)}}},Xt={key:0,class:"nav flex flex-end"},Jt=Vue.createElementVNode("span",null,"设置",-1),Qt=[Jt],eo={class:"radio-group2"},to={key:1,class:"my-box flex f14 open-post",style:{margin:"1rem 0 0 0",padding:"1rem"}},oo={class:"flex"},no={class:"msgs"},so={key:1,class:"setting-modal modal"},lo={class:"wrapper"},io=Vue.createElementVNode("div",{class:"title"}," 脚本设置 ",-1),ro=Vue.createElementVNode("div",{class:"sub-title"}," 设置自动保存到本地,下次打开依然生效 ",-1),ao={class:"option"},co=Vue.createElementVNode("span",null,"显示工具栏:",-1),uo=Vue.createElementVNode("div",{class:"notice"},[Vue.createElementVNode("div",null," 关闭此选项后,页面上所有的脚本工具栏和按钮,均不显示。 "),Vue.createElementVNode("div",null," 点击右上角插件“Tampermonkey”,找到“V2EX - 超级增强”脚本,找到“脚本设置”选项,点击可再次打开本弹框修复设置 ")],-1),mo={class:"option"},po=Vue.createElementVNode("span",null,"列表帖子展示方式:",-1),Vo={class:"radio-group2"},ho={class:"option"},fo=Vue.createElementVNode("span",null,"回复展示方式:",-1),go={class:"radio-group2"},vo={class:"option"},_o=Vue.createElementVNode("span",null,"用户打标签:",-1),wo={class:"option"},ko=Vue.createElementVNode("span",null,"帖子界面自动打开详情弹框 :",-1),yo=Vue.createElementVNode("div",{class:"notice"}," 单独打开这种地址 https://v2ex.com/t/xxxx 时, 是否自动打开详情弹框 ",-1),Eo={class:"option"},Co=Vue.createElementVNode("span",null,"点击列表的帖子,打开详情弹框 :",-1),No=Vue.createElementVNode("div",{class:"notice"}," 若关闭此项,点击列表的帖子时,不会打开弹框,会跳转网页 ",-1),To={class:"option"},xo=Vue.createElementVNode("span",null,"点击两侧空白处关闭帖子详情:",-1),So={class:"option"},Bo=Vue.createElementVNode("span",null,"正文超长自动折叠:",-1),bo={class:"option"},Mo=Vue.createElementVNode("span",null,"列表hover时显示预览按钮:",-1),Lo=Vue.createElementVNode("div",{class:"notice"}," 此项需要刷新页面才能生效 ",-1),Io=Vue.createElementVNode("div",{class:"jieshao"}," 如只想要列表预览功能,可关闭 ”点击列表的帖子,打开详情弹框“,”帖子界面自动打开详情弹框“ ",-1),Ho={key:2,class:"tag-modal modal"},Oo={class:"wrapper"},Do=Vue.createElementVNode("div",{class:"title"}," 添加标签 ",-1),Ro={class:"option"},Ao=Vue.createElementVNode("span",null,"用户:",-1),Po={class:"btns"};function Go(t,e,s,a,o,n){const c=Vue.resolveComponent("PostDetail"),m=Vue.resolveComponent("Msg"),d=Vue.resolveComponent("Base64Tooltip");return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["app-home",[o.pageType,o.isNight?"isNight":""]])},[o.config.showToolbar?(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:0},[n.isList?(Vue.openBlock(),Vue.createElementBlock("div",Xt,[Vue.createElementVNode("div",{class:"nav-item",onClick:e[0]||(e[0]=r=>o.showConfig=!0)},Qt),Vue.createElementVNode("div",eo,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="table"?"active":""]),onClick:e[1]||(e[1]=r=>o.config.viewType="table")},"表格 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="card"?"active":""]),onClick:e[2]||(e[2]=r=>o.config.viewType="card")},"卡片 ",2)])])):Vue.createCommentVNode("",!0),o.pageType==="post"?(Vue.openBlock(),Vue.createElementBlock("div",to,[Vue.createElementVNode("div",oo,[Vue.createTextVNode(" 自动打开详情弹框 : "),Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.autoOpenDetail}]),onClick:e[3]||(e[3]=r=>o.config.autoOpenDetail=!o.config.autoOpenDetail)},null,2)]),Vue.createElementVNode("div",{class:Vue.normalizeClass(["button gray",{loading:o.loading}]),onClick:e[4]||(e[4]=r=>o.show=!0)}," 点击显示详情弹框 ",2)])):Vue.createCommentVNode("",!0)],64)):Vue.createCommentVNode("",!0),Vue.createVNode(c,{modelValue:o.show,"onUpdate:modelValue":e[5]||(e[5]=r=>o.show=r),isNight:o.isNight,displayType:o.config.commentDisplayType,"onUpdate:displayType":e[6]||(e[6]=r=>o.config.commentDisplayType=r),loading:o.loading},null,8,["modelValue","isNight","displayType","loading"]),Vue.createElementVNode("div",no,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(o.msgList,r=>(Vue.openBlock(),Vue.createBlock(m,{key:r.id,type:r.type,text:r.text,onClose:u=>n.removeMsg(r.id)},null,8,["type","text","onClose"]))),128))]),Vue.createVNode(d),o.showConfig?(Vue.openBlock(),Vue.createElementBlock("div",so,[Vue.createElementVNode("div",{class:"mask",onClick:e[7]||(e[7]=r=>o.showConfig=!o.showConfig)}),Vue.createElementVNode("div",lo,[io,ro,Vue.createElementVNode("div",ao,[co,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.showToolbar}]),onClick:e[8]||(e[8]=r=>o.config.showToolbar=!o.config.showToolbar)},null,2)]),uo,Vue.createElementVNode("div",mo,[po,Vue.createElementVNode("div",Vo,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="table"?"active":""]),onClick:e[9]||(e[9]=r=>o.config.viewType="table")},"表格 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="card"?"active":""]),onClick:e[10]||(e[10]=r=>o.config.viewType="card")},"卡片 ",2)])]),Vue.createElementVNode("div",ho,[fo,Vue.createElementVNode("div",go,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===0?"active":""]),onClick:e[11]||(e[11]=r=>o.config.commentDisplayType=0)},"楼中楼 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===1?"active":""]),onClick:e[12]||(e[12]=r=>o.config.commentDisplayType=1)},"感谢最多 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===2?"active":""]),onClick:e[13]||(e[13]=r=>o.config.commentDisplayType=2)},"V2原版 ",2)])]),Vue.createElementVNode("div",vo,[_o,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.openTag}]),onClick:e[14]||(e[14]=r=>o.config.openTag=!o.config.openTag)},null,2)]),Vue.createElementVNode("div",wo,[ko,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.autoOpenDetail}]),onClick:e[15]||(e[15]=r=>o.config.autoOpenDetail=!o.config.autoOpenDetail)},null,2)]),yo,Vue.createElementVNode("div",Eo,[Co,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.clickPostItemOpenDetail}]),onClick:e[16]||(e[16]=r=>o.config.clickPostItemOpenDetail=!o.config.clickPostItemOpenDetail)},null,2)]),No,Vue.createElementVNode("div",To,[xo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.closePostDetailBySpace}]),onClick:e[17]||(e[17]=r=>o.config.closePostDetailBySpace=!o.config.closePostDetailBySpace)},null,2)]),Vue.createElementVNode("div",So,[Bo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.contentAutoCollapse}]),onClick:e[18]||(e[18]=r=>o.config.contentAutoCollapse=!o.config.contentAutoCollapse)},null,2)]),Vue.createElementVNode("div",bo,[Mo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.showPreviewBtn}]),onClick:e[19]||(e[19]=r=>o.config.showPreviewBtn=!o.config.showPreviewBtn)},null,2)]),Lo,Io])])):Vue.createCommentVNode("",!0),o.tagModal.show?(Vue.openBlock(),Vue.createElementBlock("div",Ho,[Vue.createElementVNode("div",{class:"mask",onClick:e[20]||(e[20]=Vue.withModifiers(r=>o.tagModal.show=!1,["stop"]))}),Vue.createElementVNode("div",Oo,[Do,Vue.createElementVNode("div",Ro,[Ao,Vue.createElementVNode("div",null,Vue.toDisplayString(o.tagModal.currentUsername),1)]),Vue.withDirectives(Vue.createElementVNode("input",{type:"text",autofocus:"","onUpdate:modelValue":e[21]||(e[21]=r=>o.tagModal.tag=r),onKeydown:e[22]||(e[22]=Vue.withKeys((...r)=>n.addTag&&n.addTag(...r),["enter"]))},null,544),[[Vue.vModelText,o.tagModal.tag]]),Vue.createElementVNode("div",Po,[Vue.createElementVNode("div",{class:"button info",onClick:e[23]||(e[23]=r=>o.tagModal.show=!1)},"取消"),Vue.createElementVNode("div",{class:"button",onClick:e[24]||(e[24]=(...r)=>n.addTag&&n.addTag(...r))},"确定")])])])):Vue.createCommentVNode("",!0)],2)}const zo=v(Yt,[["render",Go]]);let N;window.win().isFrame?N=$("#app",window.win().doc)[0]:N=window.win().query("#app");window.win().vue&&window.win().vue.unmount();let S=Vue.createApp(zo);window.win().vue=S;window.win().appNode=N;S.config.unwrapInjectedRef=!0;S.config.errorHandler=(t,e,s)=>{console.error("通过vue errorHandler捕获的错误"),console.error(t),console.error(e),console.error(s)};S.mount(N);
//# sourceMappingURL=index-3122660c.js.map
})
const isDev = false
if (!isDev) {
window.onerror = function (message, source, lineno, colno, error) {
console.log('捕获到异常:', {message, source, lineno, colno, error});
}
window.addEventListener('error', (error) => {
console.log('捕获到异常:', error);
}, true)
window.addEventListener("unhandledrejection", function (e) {
e.preventDefault()
console.log('捕获到异常:', e);
return true;
});
} else {
window.GM_registerMenuCommand = function () {
}
window.GM_openInTab = function () {
}
}
if (window.top !== window.self) {
window.win = () => window.top
window.baseUrl = 'https://v2ex.com'
window.win().isFrame = true
//直接使用v2的jquery,因为v2对jquery作了修改,加了一些header,缺少这些header发送请求会报403
window.$ = window.win().$
} else {
window.win = () => window
//这里必须一致。不然会报跨域
window.baseUrl = location.origin
window.win().isFrame = false
}
window.initPost = {
replies: [],
nestedReplies: [],
username: '',
title: '',
id: '',
type: 'post',
once: '',
replyCount: 0,
clickCount: 0,
thankCount: 0,
collectCount: 0,
isFavorite: false,
isIgnore: false,
isThanked: false,
isReport: false,
}
window.win().doc = window.win().document
window.win().query = (v) => window.win().document.querySelector(v)
window.clone = (val) => JSON.parse(JSON.stringify(val))
window.user = {
tagPrefix: '--用户标签--',
tags: {},
username: '',
avatar: '',
tagsId: ''
}
window.pageType = ''
window.pageData = {pageNo: 1}
window.config = {
showToolbar: true,
showPreviewBtn: true,
autoOpenDetail: true,
openTag: true,
clickPostItemOpenDetail: true,
// newTabOpen: true,
closePostDetailBySpace: true,//点击空白处关闭详情
contentAutoCollapse: true,//点击空白处关闭详情
viewType: 'card',
commentDisplayType: 0
}
window.isNight = $('.Night').length === 1
window.cb = null
window.postList = []
window.parse = {
//解析帖子内容
async parsePostContent(post = {}, body, htmlText) {
let once = htmlText.match(/var once = "([\d]+)";/)
// console.log(once)
if (once && once[1]) {
post.once = once[1]
}
post.isReport = htmlText.includes('你已对本主题进行了报告')
let topic_buttons = body.find('.topic_buttons')
if (topic_buttons.length) {
let favoriteNode = topic_buttons.find('.tb:first')
if (favoriteNode.length) {
post.isFavorite = favoriteNode[0].innerText === '取消收藏'
}
let ignoreNode = topic_buttons.find('.tb:nth-child(3)')
if (ignoreNode.length) {
post.isIgnore = ignoreNode[0].innerText === '取消忽略'
}
//
let thankNode = topic_buttons.find('#topic_thank .tb')
if (!thankNode.length) {
post.isThanked = true
}
let topic_stats = topic_buttons.find('.topic_stats')
//topic_stats = $(`<div class="fr topic_stats" style="padding-top: 4px;">9569 次点击 ∙ 28 人收藏 ∙ 1 人感谢 </div>`)
//收藏数、感谢数
if (topic_stats.length) {
let text = topic_stats[0].innerText
let reg1 = text.matchAll(/([\d]+)[\s]*人收藏/g)
let collectCountReg = [...reg1]
if (collectCountReg.length) {
post.collectCount = Number(collectCountReg[0][1])
}
// console.log([...collectCountReg])
let reg2 = text.matchAll(/([\d]+)[\s]*人感谢/g)
let thankCountReg = [...reg2]
if (thankCountReg.length) {
post.thankCount = Number(thankCountReg[0][1])
}
let reg3 = text.matchAll(/([\d]+)[\s]*次点击/g)
let clickCountReg = [...reg3]
if (clickCountReg.length) {
post.clickCount = Number(clickCountReg[0][1])
}
// console.log([...thankCountReg])
}
}
// console.log('基本信息', post)
body.find('.topic_buttons').remove()
let header = body.find('#Main .box').first()
post.headerTemplate = `${header.html()} `
return post
},
//获取帖子所有回复
async getPostAllReplies(post = {}, body, htmlText, pageNo = 1) {
if (body.find('#no-comments-yet').length) {
return post
}
let box = body.find('#Main > .box')[1]
let cells = box.querySelectorAll('.cell')
post.fr = cells[0].querySelector('.cell .fr').innerHTML
cells = Array.from(cells)
//获取创建时间
let snow = cells[0].querySelector('.snow')
post.createDate = snow?.nextSibling.nodeValue.trim() || ''
let repliesMap = []
if (cells[1].id) {
repliesMap.push({i: pageNo, replyList: this.parsePageReplies(cells.slice(1))})
let replies = this.getAllReply(repliesMap)
post.replies = replies
post.replyCount = replies.length
post.allReplyUsers = Array.from(new Set(replies.map(v => v.username)))
let nestedList = this.createNestedList(replies, post.allReplyUsers)
if (nestedList) post.nestedReplies = nestedList
return post
} else {
let promiseList = []
// console.log(this.current.repliesMap)
return new Promise((resolve, reject) => {
repliesMap.push({i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1))})
let pages = cells[1].querySelectorAll('a')
pages = Array.from(pages)
// console.log(pages)
let url = window.baseUrl + '/t/' + post.id
for (let i = 0; i < pages.length; i++) {
let currentPageNo = Number(pages[i].innerText)
if (currentPageNo == pageNo) continue
promiseList.push(this.fetchPostOtherPageReplies(url + '?p=' + currentPageNo, currentPageNo))
}
Promise.allSettled(promiseList).then(
(results) => {
results.filter((result) => result.status === "fulfilled").map(v => repliesMap.push(v.value))
let replies = this.getAllReply(repliesMap)
post.replies = replies
post.replyCount = replies.length
post.allReplyUsers = Array.from(new Set(replies.map(v => v.username)))
let nestedList = this.createNestedList(replies, post.allReplyUsers)
if (nestedList) post.nestedReplies = nestedList
resolve(post)
}
);
})
}
},
//请求帖子其他页的回复
fetchPostOtherPageReplies(url, pageNo) {
return new Promise(resolve => {
$.get(url).then(res => {
let s = res.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
let box = $(s[0]).find('#Main .box')[1]
let cells = box.querySelectorAll('.cell')
cells = Array.from(cells)
resolve({i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1))})
})
})
},
//解析页面的回复
parsePageReplies(nodes) {
let replyList = []
nodes.forEach((node, index) => {
if (!node.id) return
let item = {
thankCount: 0,
isThanked: false,
isOp: false,
id: node.id.replace('r_', '')
}
let reply_content = node.querySelector('.reply_content')
// console.log('reply_content',reply_content)
item.reply_content = reply_content.innerHTML
item.reply_text = reply_content.innerText
let {users, floor} = this.parseReplyContent(item.reply_content)
item.replyUsers = users
item.replyFloor = floor
if (index === 5) {
// console.log(item)
// console.log(reply_content.innerText)
// console.log(reply_content.innerHTML)
}
let ago = node.querySelector('.ago')
item.date = ago.innerText
let userNode = node.querySelector('strong a')
item.username = userNode.innerText
let avatar = node.querySelector('td img')
item.avatar = avatar.src
let no = node.querySelector('.no')
item.floor = Number(no.innerText)
let thank_area = node.querySelector('.thank_area')
if (thank_area) {
item.isThanked = thank_area.classList.contains('thanked')
}
let small = node.querySelector('.small')
if (small) {
item.thankCount = Number(small.innerText)
}
let op = node.querySelector('.op')
if (op) {
item.isOp = true
}
let mod = node.querySelector('.mod')
if (mod) {
item.isMod = true
}
// console.log('item', item)
replyList.push(item)
})
return replyList
},
//解析回复内容,解析出@用户,回复楼层。用于后续生成嵌套楼层
parseReplyContent(str) {
if (!str) return
let users = []
let getUsername = (userStr) => {
let endIndex = userStr.indexOf('">')
if (endIndex > -1) {
let user = userStr.substring(0, endIndex)
if (!users.find(i => i === user)) {
users.push(user)
}
}
}
// str = `@<a hr a> #4 @<a1 href="/member/Eiden1">Eiden1</a1> @<a href="/member/Eiden111">Eiden21</a> #11 这也是执行阶段,所谓的安装也是程序业务的 setup 。<br>windows 、Android 并没有系统级的 CD-KEY 。`
let floorReg = /@<a href="\/member\/[\s\S]+?<\/a>[\s]+#([\d]+)/g
let userReg = /@<a href="\/member\/([\s\S]+?)<\/a>/g
let hasFloor = str.matchAll(floorReg)
let res = [...hasFloor]
// console.log('总匹配', res)
let floor = -1
if (res.length) {
floor = Number(res[0][1])
}
let has = str.matchAll(userReg)
let res2 = [...has]
// console.log('总匹配', res2)
if (res2.length > 1) {
res2.map(item => {
getUsername(item[1])
})
}
if (res2.length === 1) {
getUsername(res2[0][1])
}
// console.log('用户', users)
// console.log('楼层', floor)
return {users, floor}
},
//获取帖子详情
async getPostDetail(post = {}, body, htmlText, pageNo = 1) {
post = await this.parsePostContent(post, body, htmlText)
return await this.getPostAllReplies(post, body, htmlText, pageNo)
},
getAllReply(repliesMap = []) {
return repliesMap.sort((a, b) => a.i - b.i).reduce((pre, i) => {
pre = pre.concat(i.replyList)
return pre
}, [])
},
//生成嵌套回复
createNestedList(allList = []) {
if (!allList.length) return []
if ((Date.now() - window.win().lastCallDate) < 1000) {
// console.log('短时间内,重复调用,因为监听了replies,所以打开时会触发两次。第二次不管他')
return false
}
// console.log('cal-createNestedList', Date.now())
let list = JSON.parse(JSON.stringify(allList))
let nestedList = []
list.map((item, index) => {
let startList = list.slice(0, index)
//用于918489这种情况,@不存在的人
let startReplyUsers = Array.from(new Set(startList.map(v => v.username)))
let endList = list.slice(index + 1)
if (index === 0) {
item.level = 0
nestedList.push(this.findChildren(item, endList, list))
} else {
if (!item.isUse) {
//是否是一级回复
let isOneLevelReply = false
// if (item.replyFloor === -1) {
// isOneLevelReply = true
// }
if (item.replyUsers.length) {
if (item.replyUsers.length > 1) {
isOneLevelReply = true
} else {
isOneLevelReply = !startReplyUsers.find(v => v === item.replyUsers[0]);
}
} else {
isOneLevelReply = true
}
if (isOneLevelReply) {
item.level === 0
nestedList.push(this.findChildren(item, endList, list))
}
}
}
})
// console.log('replies长度', allList)
// console.log('nestedList长度', nestedList)
window.win().lastCallDate = Date.now()
return nestedList
},
//查找子回复
findChildren(item, endList, all) {
const fn = (child, endList2, parent) => {
child.level = parent.level + 1
let rIndex = all.findIndex(v => v.floor === child.floor)
if (rIndex > -1) {
all[rIndex].isUse = true
}
parent.children.push(this.findChildren(child, endList2, all))
}
// console.log('endList', endList)
item.children = []
// if (item.floor ==8)debugger
for (let i = 0; i < endList.length; i++) {
let currentItem = endList[i]
//如果已被使用,直接跳过
if (currentItem.isUse) continue
let endList2 = endList.slice(i + 1)
if (currentItem.replyUsers.length === 1) {
//如果是下一条是同一人的回复,那么跳出循环
if (currentItem.username === item.username) {
//自己回复自己的特殊情况
if (currentItem.replyUsers[0] === item.username) {
fn(currentItem, endList2, item)
}
return item
} else {
if (currentItem.replyUsers[0] === item.username) {
fn(currentItem, endList2, item)
}
}
} else {
//下一条是同一人的回复,并且均未@人。直接跳过
if (currentItem.username === item.username) return item
}
}
return item
},
findChildren2(item, endList, all) {
const fn = (child, endList2, parent) => {
child.level = parent.level + 1
let rIndex = all.findIndex(v => v.floor === child.floor)
if (rIndex > -1) {
all[rIndex].isUse = true
}
parent.children.push(this.findChildren(child, endList2, all))
}
// console.log('endList', endList)
item.children = []
// if (item.floor ==8)debugger
for (let i = 0; i < endList.length; i++) {
let currentItem = endList[i]
//如果已被使用,直接跳过
if (currentItem.isUse) continue
let endList2 = endList.slice(i + 1)
//注: 2022-10-26,回复被忽略、用户被ban,会占据原来的楼层,以楼层号来判断会出问题
// if (currentItem.replyFloor !== -1) {
// if (currentItem.replyFloor === item.floor) {
// fn(currentItem, endList2, item)
// }
// }
if (currentItem.replyUsers.length) {
// //找出自己最近一条正常回复,以那条为搜索终点
// let rIndex = endList.findIndex(v => v.username === item.username && (currentItem.replyUsers.length === 0 && currentItem.replyFloor === -1))
// if (rIndex > -1) {
// endList2 = endList.slice(i + 1, rIndex)
// }
//如果是下一条是同一人的回复,那么跳出循环。children从下一条开始找
if (currentItem.username === item.username) {
//自己回复自己的特殊情况
if (currentItem.replyUsers[0] === item.username) {
fn(currentItem, endList2, item)
continue
}
//有种特殊情况,就是自己连着评论了两条。然后后面的人以#号的方式 回复了自己第一条。
//如果检测到下条是自己的回复,直接略过的话就会丢失第一条的所有楼中楼回复
//具体如下
// 自己:1楼,在for的时候,如果碰到 2楼不能直接跳过,直接略过的话就会丢失第一条的所有楼中楼回复,即3楼。所以应该以3楼为起点
//进行楼中楼查找,查找完了再跳过
// 自己:2楼
// 别人:指定回复1楼
// endList2.map((v, vi) => {
// if (v.replyFloor === item.floor) {
// fn(v, endList.slice(vi + 1), item)
// }
// })
break
} else {
if (currentItem.replyUsers[0] === item.username) {
fn(currentItem, endList2, item)
}
}
} else {
//下一条是同一人的回复,并且均未@人。直接跳过
if (currentItem.username === item.username) return item
}
}
return item
},
//解析其他页面
parseOtherPage(html, pageType) {
let bodyText = html.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
let body = $(bodyText[0])
if (pageType === 'recent') {
let list = body.find('.item')
let res = this.parsePagePostList(Array.from(list))
let page = body.find('.cell:last').html()
return {...res, page}
}
if (pageType === 'nodePage') {
let topics = body.find('#TopicsNode')
let list = topics.children()
let res = this.parsePagePostList(Array.from(list))
let page = topics.next().html()
return {...res, page}
}
},
//解析页面帖子列表
parsePagePostList(list, box) {
list.forEach(itemDom => {
let item = window.clone(window.initPost)
let item_title = itemDom.querySelector('.item_title a')
let {href, id} = window.parse.parseA(item_title)
item.id = id
item.href = href
item.url = window.win().location.origin + '/api/topics/show.json?id=' + item.id
itemDom.classList.add('post-item')
itemDom.classList.add(`id_${id}`)
window.postList.push(item)
})
Promise.allSettled(window.postList.map(item => $.get(item.url))).then(
res => {
let ok = res.filter((r) => r.status === "fulfilled").map(v => v.value[0])
// let fail = res.filter((r) => r.status === "rejected")
box.style.boxShadow = 'unset'
box.style.background = 'unset'
if (window.config.viewType === 'card') {
list.forEach(itemDom => {
itemDom.classList.add('preview')
})
}
ok.map(postItem => {
let itemDom = box.querySelector(`.id_${postItem.id}`)
if (window.config.showPreviewBtn) {
//添加切换按钮
let td = itemDom.querySelector('td:nth-child(4)')
td.style.position = 'relative'
let toggle = document.createElement('div')
toggle.dataset['id'] = postItem.id
toggle.classList.add('toggle')
toggle.innerText = '点击展开/收起'
td.append(toggle)
}
let index = window.postList.findIndex(v => v.id == postItem.id)
if (index > -1) {
let obj = window.postList[index]
window.postList[index] = Object.assign({}, obj, postItem)
if (postItem.content_rendered) {
let a = document.createElement('a')
a.href = obj.href
a.classList.add('post-content')
let div = document.createElement('div')
div.innerHTML = postItem.content_rendered
a.append(div)
// console.log(div.clientHeight)
itemDom.append(a)
}
}
})
cbChecker({type: 'syncData'})
}
)
},
parseA(a) {
let href = a.href
let id
if (href.includes('/t/')) {
if (href.includes('#')) {
id = href.substring(href.indexOf('/t/') + 3, href.indexOf('#'))
} else {
id = href.substring(href.indexOf('/t/') + 3,)
}
}
return {href, id}
},
//创建记事本里面的tag标签
async createTagNote() {
let data = new FormData()
data.append('content', '--用户标签--')
data.append('parent_id', 0)
data.append('syntax', 0)
let apiRes = await window.win().fetch(`${window.baseUrl}/notes/new`, {method: 'post', body: data})
console.log(apiRes)
if (apiRes.redirected && apiRes.status === 200) {
//成功
return apiRes.url.substr(-5)
}
return null
},
//标签操作
async saveTags(val) {
let data = new FormData()
data.append('content', window.user.tagPrefix + JSON.stringify(val))
data.append('syntax', 0)
let apiRes = await window.win().fetch(`${window.baseUrl}/notes/edit/${window.user.tagsId}`, {
method: 'post', body: data
})
return apiRes.redirected && apiRes.status === 200;
}
}
async function sleep(time) {
return new Promise(resolve => {
// console.log('等待vue加载完成,第' + count + '次', Date.now())
setTimeout(resolve, time)
})
}
async function cbChecker(val, count = 0) {
if (window.cb) {
window.cb(val)
} else {
while ((!window.cb) && count < 20) {
await sleep(500)
count++
}
window.cb && window.cb(val)
}
}
//初始化脚本菜单
function initMonkeyMenu() {
GM_registerMenuCommand("脚本设置", function (event) {
cbChecker({type: 'openSetting'})
});
GM_registerMenuCommand('💬 反馈 & 建议', function () {
GM_openInTab('https://github.com/zyronon/v2ex-script/issues', {
active: true,
insert: true,
setParent: true
});
});
}
//初始化样式表
function initStyle() {
//给Wrapper和content取消宽高,是因为好像是v2的屏蔽机制,时不时会v2会修复这两个div的宽高,让网页变形
let style2 = `
html, body {
font-size: 62.5%;
}
#Wrapper {
height: unset !important;
width: unset !important;
}
#Wrapper > .content {
height: unset !important;
width: unset !important;
}
.post-item {
background: white;
}
.post-item > .post-content {
height: 0;
margin-top: 0;
}
.post-item:hover .toggle {
display: flex;
}
.toggle {
position: absolute;
right: 0;
top: 0.5rem;
width: 8rem;
height: 100%;
display: flex;
justify-content: flex-end;
align-items: flex-end;
cursor: pointer;
font-size: 1.2rem;
color: #ccc;
display: none;
}
.preview {
margin: 1rem 0;
border: 1px solid #e2e2e2;
border-radius: 0.4rem;
cursor: pointer;
}
.preview:hover {
border: 1px solid #968b8b;
}
.preview > .post-content {
height: unset !important;
margin-top: 0.5rem !important;
}
.post-content {
margin-top: 0.5rem;
display: block;
max-height: 20rem;
overflow: hidden;
text-decoration: unset !important;
line-break: anywhere;
}
.post-content:link {
color: black;
}
.post-content:visited {
color: #afb9c1 !important;
}
.Night .post-item {
background: #18222d !important;
}
.Night .preview {
border: 1px solid #3b536e;
}
.Night .preview > .post-content:link {
color: #d1d5d9;
}
.Night .preview > .post-content:visited {
color: #393f4e !important;
}
`
let addStyle2 = document.createElement("style");
addStyle2.rel = "stylesheet";
addStyle2.type = "text/css";
addStyle2.innerHTML = style2
$(window.win().doc.head).append(addStyle2)
}
initMonkeyMenu()
initStyle()
window.win().canParseV2exPage = true
if (window.win().canParseV2exPage) {
let location2 = window.win().location
if (location2.pathname === '/') {
window.pageType = 'home'
} else if (location2.href.match(/.com\/?tab=/)) {
window.pageType = 'home'
} else if (location2.href.match(/.com\/go\//)) {
if (!location2.href.includes('/links')) {
window.pageType = 'nodePage'
}
} else if (location2.href.match(/.com\/recent/)) {
window.pageType = 'recent'
} else {
let r = location2.href.match(/.com\/t\/([\d]+)/)
if (r) {
window.pageType = 'post'
window.pageData.id = r[1]
if (location2.search) {
let pr = location2.href.match(/\?p=([\d]+)/)
if (pr) window.pageData.pageNo = Number(pr[1])
}
}
}
let top2 = window.win().query('.tools .top:nth-child(2)').text
if (top2 !== '注册') {
window.user.username = top2
window.user.avatar = $('#Rightbar .box .avatar', window.win().doc).attr('src')
cbChecker({type: 'syncData'})
//获取或创建记事本的标签
$.get(window.baseUrl + '/notes').then(r => {
let bodyText = r.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
let body = $(bodyText[0])
let items = body.find('#Main .box .note_item_title a')
let needCreateNoteTags = true
if (items.length) {
let tags = Array.from(items).find(v => v.innerText.includes(window.user.tagPrefix))
if (tags) {
needCreateNoteTags = false
window.user.tagsId = tags.href.substr(-5)
cbChecker({type: 'syncData'})
$.get(window.baseUrl + '/notes/edit/' + window.user.tagsId).then(r2 => {
bodyText = r2.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
body = $(bodyText[0])
let text = body.find('.note_editor').text()
if (text === window.user.tagPrefix) {
window.user.tags = {}
} else {
let tagJson = text.substring(window.user.tagPrefix.length)
try {
window.user.tags = JSON.parse(tagJson)
} catch (e) {
console.log('tage', tagJson)
window.user.tags = {}
}
}
cbChecker({type: 'syncData'})
})
}
}
if (needCreateNoteTags) {
window.parse.createTagNote().then(r => {
if (r) {
window.user.tagsId = r
window.user.tags = {}
cbChecker({type: 'syncData'})
}
})
}
})
}
//获取默认配置
let configStr = window.win().localStorage.getItem('v2ex-config')
if (configStr) {
let configObj = JSON.parse(configStr)
configObj = configObj[window.user.username ?? 'default']
if (configObj) {
window.config = Object.assign(window.config, configObj)
}
}
let $section = document.createElement('section')
$section.id = 'app'
let box
let list
switch (window.pageType) {
case 'nodePage':
box = window.win().doc.querySelectorAll('#Wrapper #Main .box')
let topics = box[1].querySelector('#TopicsNode')
list = topics.querySelectorAll('.cell')
list[0].before($section)
window.parse.parsePagePostList(list, box[1])
break
case 'recent':
case 'home':
box = window.win().query('#Wrapper #Main .box')
list = box.querySelectorAll('.item')
list[0].before($section)
window.parse.parsePagePostList(list, box)
break
case 'post':
box = window.win().query('#Wrapper #Main .box')
box.after($section)
window.parse.parsePostContent(
{id: window.pageData.id},
$(window.win().doc.body),
window.win().doc.documentElement.outerHTML
).then(async res => {
// console.log('详情页-基本信息解析完成', new Date())
window.pageData.post = res
await cbChecker({type: 'postContent', value: res}, 0)
})
window.parse.getPostAllReplies(
{id: window.pageData.id},
$(window.win().doc.body),
window.win().doc.documentElement.outerHTML,
window.pageData.pageNo
).then(async res => {
// console.log('详情页-回复解析完成', new Date())
window.pageData.post = Object.assign(window.pageData.post, res)
await cbChecker({type: 'postReplies', value: res}, 0)
})
break
default:
console.error('未知页面')
break
}
}
})();