V2EX - 超级增强

楼中楼回复(支持感谢数排序)、列表预览内容、点击帖子弹框展示详情、对用户打标签、正文超长自动折叠、划词 base64 解码、一键@所有人,@管理员、操作按钮(感谢、收藏、回复、隐藏)异步请求、支持黑暗模式

当前为 2023-04-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name V2EX - 超级增强
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.2.8
  5. // @description 楼中楼回复(支持感谢数排序)、列表预览内容、点击帖子弹框展示详情、对用户打标签、正文超长自动折叠、划词 base64 解码、一键@所有人,@管理员、操作按钮(感谢、收藏、回复、隐藏)异步请求、支持黑暗模式
  6. // @author Zyronon
  7. // @match https://*.v2ex.com/
  8. // @match https://*.v2ex.com/?tab=*
  9. // @match https://*.v2ex.com/t/*
  10. // @match https://*.v2ex.com/recent*
  11. // @match https://*.v2ex.com/go/*
  12. // @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
  13. // @require https://cdn.bootcdn.net/ajax/libs/vue/3.2.47/vue.runtime.global.prod.min.js
  14. // @grant GM_registerMenuCommand
  15. // @grant GM_unregisterMenuCommand
  16. // @grant GM_openInTab
  17. // @license GPL License
  18. // ==/UserScript==
  19.  
  20. (function () {
  21.  
  22.  
  23.  
  24. let style = `
  25. 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;border:1px solid #ccc;transition:all .3s}.switch.active{background:#ccc}.switch.active:before{right:.2rem;background:white}.switch:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%;background:#ccc}.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-721ac04c]{flex-direction:row!important;padding:0!important}.horizontal .num[data-v-721ac04c]{margin-left:.2rem}.point[data-v-721ac04c]{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-721ac04c]{display:flex;flex-direction:column;align-items:center;justify-content:center}.point .num[data-v-721ac04c]{font-weight:700;color:#000;user-select:none}.point svg[data-v-721ac04c]{width:2rem;padding:.4rem;border-radius:.2rem}.point svg[data-v-721ac04c]:hover{background:#e5e5e5}.point .disabled[data-v-721ac04c]:hover{background:unset}.Author[data-v-09f2f7fd]{display:flex;align-items:center;justify-content:space-between;font-size:1.2rem;position:relative;margin-bottom:.4rem}.Author.expand[data-v-09f2f7fd]{margin-bottom:0}.Author .Author-left[data-v-09f2f7fd]{display:flex;align-items:center;max-width:90%}.Author .Author-left .username[data-v-09f2f7fd]{font-size:1.4rem;margin-right:1rem}.Author .Author-left .expand-icon[data-v-09f2f7fd]{cursor:pointer;margin-right:.8rem;width:2rem;height:2rem;transform:rotate(90deg)}.Author .Author-left .icon[data-v-09f2f7fd]{margin-right:1rem;display:flex}.Author .Author-left .icon img[data-v-09f2f7fd]{width:3.4rem;height:3.4rem;border-radius:.3rem}.Author .Author-left .texts[data-v-09f2f7fd]{flex:1}.Author .Author-left .op[data-v-09f2f7fd]{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-09f2f7fd]{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-09f2f7fd]{font-size:1.3rem;font-weight:700;color:red;margin-left:1rem}.Author .Author-left .my-tag:hover .remove[data-v-09f2f7fd]{display:inline}.Author .Author-left .my-tag .remove[data-v-09f2f7fd]{cursor:pointer;margin-left:.5rem;display:none}.Author .Author-left .add-tag[data-v-09f2f7fd]{font-size:2rem;line-height:1rem;display:inline-block;margin-left:1rem;cursor:pointer;display:none}.Author:hover .add-tag[data-v-09f2f7fd]{display:inline-block}.Author .Author-right[data-v-09f2f7fd]{position:absolute;right:0;display:flex;align-items:center}.Author .Author-right .toolbar[data-v-09f2f7fd]{display:flex;align-items:center;color:#929596;opacity:0}.Author .Author-right .toolbar[data-v-09f2f7fd]:hover{background:white;opacity:1}.Author .Author-right .floor[data-v-09f2f7fd]{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-09f2f7fd]{color:#000!important}.post-editor-wrapper[data-v-0048db38]{width:100%;box-sizing:border-box;position:relative;overflow:hidden;transition:all .3s}.post-editor-wrapper.reply-post .post-editor[data-v-0048db38]{border:1px solid #e2e2e2;border-radius:.4rem}.post-editor-wrapper.reply-post.isFocus .post-editor[data-v-0048db38]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment[data-v-0048db38]{border:1px solid #e2e2e2;border-radius:.4rem;overflow:hidden}.post-editor-wrapper.reply-comment.isFocus[data-v-0048db38]{border:1px solid #968b8b}.post-editor-wrapper.reply-comment .toolbar[data-v-0048db38]{background:#f6f7f8}.post-editor-wrapper .post-editor[data-v-0048db38]{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-0048db38]{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-0048db38]{color:gray;font-size:1.3rem}.post-editor-wrapper .get-cursor[data-v-0048db38]{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-0bf60eab],body[data-v-0bf60eab]{font-size:62.5%}.flex[data-v-0bf60eab]{display:flex;align-items:center;justify-content:space-between}.flex-end[data-v-0bf60eab]{justify-content:flex-end}.flex-center[data-v-0bf60eab]{justify-content:center}.p1[data-v-0bf60eab]{padding:1rem}.p0[data-v-0bf60eab]{padding:0!important}.post-author[data-v-0bf60eab]{display:flex;align-items:center;position:relative;color:#ccc!important}.post-author>.username[data-v-0bf60eab]{font-size:1.2rem}.sticky[data-v-0bf60eab]{position:sticky;bottom:0}.sticky[stuck][data-v-0bf60eab]{box-shadow:0 2px 20px #00000059}a[data-v-0bf60eab]{color:#778087;text-decoration:none;cursor:pointer}a[data-v-0bf60eab]:hover{text-decoration:underline}.base-loading[data-v-0bf60eab]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-0bf60eab infinite 1s linear}.loading-c[data-v-0bf60eab]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-0bf60eab infinite 1s linear;width:3rem;height:3rem}.loading-b[data-v-0bf60eab]{border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-0bf60eab 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-0bf60eab{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.button[data-v-0bf60eab]{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-0bf60eab]{color:#000;border:1px solid #40a9ff;background:white}.button.gray[data-v-0bf60eab]{color:#fff;border:1px solid #b6b6b6;background:#b6b6b6}.button[data-v-0bf60eab]:hover{opacity:.9}.button[data-v-0bf60eab]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-0bf60eab infinite 1s linear;border-color:#fff transparent transparent transparent;width:1rem;height:1rem;margin-right:1rem;display:none}.button.loading[data-v-0bf60eab]{cursor:not-allowed;opacity:.5}.button.loading[data-v-0bf60eab]:before{display:block}.button.disabled[data-v-0bf60eab]{cursor:not-allowed;color:#c6c6c6;background:#8d8d8d;border:1px solid transparent}.tool[data-v-0bf60eab]{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-0bf60eab]:before{content:" ";border:2px solid;border-color:#000 #00000033 #00000033 #00000033;border-radius:100%;animation:circle-0bf60eab infinite 1s linear;border-color:transparent #929596 #929596 #929596;width:1rem;height:1rem;margin-left:1rem;display:none}.tool.loading[data-v-0bf60eab]{cursor:not-allowed;opacity:.5}.tool.loading[data-v-0bf60eab]:before{display:block}.tool.loading[data-v-0bf60eab]:hover{background:unset}.tool>svg[data-v-0bf60eab]{width:1.6rem!important;height:1.6rem!important;margin-right:.4rem;box-sizing:border-box;border-radius:.2rem}.tool[data-v-0bf60eab]:hover{background:#e8e8e8}.tool.no-hover[data-v-0bf60eab]{cursor:default}.tool.no-hover[data-v-0bf60eab]:hover{background:unset}.my-node[data-v-0bf60eab]{border-radius:.2rem;padding:.4rem;font-size:1rem;color:#999;background:#f5f5f5;cursor:pointer}.my-node[data-v-0bf60eab]:hover{text-decoration:none;background:#e2e2e2}.msgs[data-v-0bf60eab]{position:fixed;margin-left:calc(50% - 25rem);width:50rem;z-index:9999;bottom:0;left:0;right:0}.msg[data-v-0bf60eab]{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-0bf60eab]{background:#40a9ff}.msg.warning .left[data-v-0bf60eab]{background:#c8c002}.msg.error .left[data-v-0bf60eab]{background:red}.msg .left[data-v-0bf60eab]{border-radius:.4rem 0 0 .4rem;display:flex;align-items:center;background:#40a9ff}.msg .left svg[data-v-0bf60eab]{margin:0 .3rem;cursor:pointer}.msg .right[data-v-0bf60eab]{flex:1;padding:1rem 2rem;display:flex;justify-content:space-between;align-items:center}.line[data-v-0bf60eab]{border-bottom:1px solid #e2e2e2}.my-box[data-v-0bf60eab]{box-shadow:0 2px 3px #0000001a;border-radius:.4rem;background:white;margin-bottom:2rem;width:100%;box-sizing:border-box}.my-cell[data-v-0bf60eab]{padding:1rem;font-size:1.4rem;line-height:150%;text-align:left;border-bottom:1px solid #e2e2e2}.f14[data-v-0bf60eab]{font-size:1.4rem}.switch[data-v-0bf60eab]{width:4.5rem;height:2.2rem;border-radius:2rem;position:relative;display:flex;align-items:center;border:1px solid #ccc;transition:all .3s}.switch.active[data-v-0bf60eab]{background:#ccc}.switch.active[data-v-0bf60eab]:before{right:.2rem;background:white}.switch[data-v-0bf60eab]:before{position:absolute;content:" ";transition:all .3s;right:calc(100% - 2rem);width:1.8rem;height:1.8rem;border-radius:50%;background:#ccc}.modal[data-v-0bf60eab]{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-0bf60eab]{font-size:2.4rem;margin-bottom:1rem;text-align:center}.modal .option[data-v-0bf60eab]{display:flex;justify-content:space-between;align-items:center;padding:.8rem 0}.modal .mask[data-v-0bf60eab]{position:fixed;width:100vw;height:100vh;left:0;top:0;background:rgba(0,0,0,.3)}.radio-group2[data-v-0bf60eab]{display:inline-flex;border-radius:.5rem;overflow:hidden;border:1px solid #e2e2e2}.radio-group2 .radio[data-v-0bf60eab]{cursor:pointer;background:transparent;padding:.5rem 1.5rem;border-left:1px solid #e2e2e2;color:#9ca1a4}.radio-group2 .radio[data-v-0bf60eab]:first-child{border-left:none}.radio-group2 .active[data-v-0bf60eab]{background:#e2e2e2;color:gray}.html-wrapper[data-v-0bf60eab]{position:relative}.html-wrapper .mask[data-v-0bf60eab]{max-height:90rem;overflow:hidden;-webkit-mask-image:linear-gradient(180deg,#000 80%,transparent)}.html-wrapper .expand[data-v-0bf60eab]{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-55446f68]{width:100%;box-sizing:border-box;margin-top:1rem;background:white}.comment .comment-content-w[data-v-55446f68]{background:white}.comment .comment-content-w .more[data-v-55446f68]{text-align:center;margin:2rem 0}.comment .comment-content[data-v-55446f68]{display:flex;position:relative}.comment .comment-content .expand-line[data-v-55446f68]{cursor:pointer;width:3rem;min-width:3rem;position:relative}.comment .comment-content .expand-line[data-v-55446f68]:after{position:absolute;left:calc(60% - 1px);content:" ";height:100%;width:0;border-right:1px solid #f1f1f1}.comment .comment-content .expand-line[data-v-55446f68]:hover:after{border-right:2px solid #0079D3}.comment .comment-content .right[data-v-55446f68]{flex:1;width:calc(100% - 3rem)}.comment .comment-content .right .w[data-v-55446f68]{padding-left:1.7rem}.comment .comment-content .right .w .text[data-v-55446f68]{color:#000;word-break:break-word}.comment .comment-content .right .w .warning[data-v-55446f68]{border-top:1px solid #e1e1e1;border-bottom:1px solid #e1e1e1;padding:1rem 0;margin-top:1rem;font-size:1.2rem;color:red}.comment .comment-content .right .w .post-editor-wrapper[data-v-55446f68]{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[data-v-09d5e1ca]{position:unset!important;background:transparent!important}.post .main[data-v-09d5e1ca]{background:transparent!important;padding:unset!important;width:100%!important}.post .close-btn[data-v-09d5e1ca]{display:none}.post-detail[data-v-09d5e1ca]{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-09d5e1ca]{background:rgba(46,47,48,.8)}.post-detail.isNight .main[data-v-09d5e1ca]{background:#22303f}.post-detail.isNight .main .my-box[data-v-09d5e1ca]{color:#fff;background:#18222d}.post-detail.isNight .main .my-box .title[data-v-09d5e1ca],.post-detail.isNight .main .my-box .content[data-v-09d5e1ca]{color:#d1d5d9!important}.post-detail.isNight .main .my-box .base-info[data-v-09d5e1ca],.post-detail.isNight .main .my-box .content[data-v-09d5e1ca]{border:1px solid #22303f!important}.post-detail.isNight .main[data-v-09d5e1ca] .subtle .fade{color:#b2c3d4!important}.post-detail.isNight .main[data-v-09d5e1ca] .subtle .topic_content{color:#d1d5d9!important}.post-detail.isNight .main .my-cell[data-v-09d5e1ca]{border-bottom:1px solid #22303f!important}.post-detail.isNight .main[data-v-09d5e1ca] .comment{background:#18222d}.post-detail.isNight .main[data-v-09d5e1ca] .comment .expand-line:after{border-right:1px solid #202c39!important}.post-detail.isNight .main[data-v-09d5e1ca] .comment .expand-line:hover:after{border-right:2px solid #0079D3!important}.post-detail.isNight .main[data-v-09d5e1ca] .comment .comment-content{background:#18222d!important}.post-detail.isNight .main[data-v-09d5e1ca] .comment .comment-content .w>.text{color:#d1d5d9!important}.post-detail.isNight .main[data-v-09d5e1ca] .Author-right .toolbar:hover{background:#18222d!important}.post-detail.isNight .main[data-v-09d5e1ca] .Author-right .tool{background:#22303f!important}.post-detail.isNight .main[data-v-09d5e1ca] .point{margin-left:.5rem}.post-detail.isNight .main[data-v-09d5e1ca] .point svg:hover{background:#22303f}.post-detail.isNight .main[data-v-09d5e1ca] .point .num{color:#d1d5d9!important}.post-detail.isNight .main[data-v-09d5e1ca] .floor{background:#393f4e!important;color:#d1d5d9!important}.post-detail.isNight .main .editor-wrapper[data-v-09d5e1ca]{background:#393f4e!important}.post-detail.isNight .main[data-v-09d5e1ca] .post-editor-wrapper .post-editor{background:#18222d;border:transparent;color:#fff}.post-detail.isNight .main[data-v-09d5e1ca] .post-editor-wrapper .toolbar{background:#393f4e!important}.post-detail.isNight .main .call-list[data-v-09d5e1ca]{background:#22303f}.post-detail.isNight .main .call-list .call-item[data-v-09d5e1ca]{border-top:1px solid #18222d}.post-detail.isNight .main .call-list .call-item .select[data-v-09d5e1ca],.post-detail.isNight .main .call-list .call-item[data-v-09d5e1ca]:hover,.post-detail.isNight .main .call-list .call-item.select[data-v-09d5e1ca]{background-color:#393f4e;text-decoration:none}.post-detail .main[data-v-09d5e1ca]{display:flex;justify-content:flex-end;padding:3rem 8rem 15rem;background:#e2e2e2;position:relative}.post-detail .main .main-wrapper[data-v-09d5e1ca]{width:77rem;padding-bottom:2rem;display:flex;flex-direction:column;align-items:center}.post-detail .main .main-wrapper .post-wrapper .toolbar-wrapper[data-v-09d5e1ca]{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-09d5e1ca]{margin-right:2rem}.post-detail .main .main-wrapper .editor-wrapper .w[data-v-09d5e1ca]{padding:1.2rem}.post-detail .main .main-wrapper .comment-wrapper .comments[data-v-09d5e1ca]{width:100%;box-sizing:border-box}.post-detail .main .main-wrapper .loading-wrapper[data-v-09d5e1ca]{height:20rem;display:flex;justify-content:center;align-items:center}.post-detail .main .main-wrapper #no-comments-yet[data-v-09d5e1ca]{color:#a9a9a9;font-weight:700;text-align:center;width:100%;margin-bottom:2rem;box-sizing:border-box}.post-detail .main .call-list[data-v-09d5e1ca]{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-09d5e1ca]{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-09d5e1ca],.post-detail .main .call-list .call-item[data-v-09d5e1ca]:hover,.post-detail .main .call-list .call-item.select[data-v-09d5e1ca]{background-color:#f0f0f0;text-decoration:none}.post-detail .main .call-list .call-item[data-v-09d5e1ca]:nth-child(1){border-top:1px solid transparent}@media screen and (max-width: 1500px){.post-detail .main-wrapper[data-v-09d5e1ca]{width:65vw!important}}@media screen and (max-width: 1280px){.post-detail .main-wrapper[data-v-09d5e1ca]{width:75vw!important}}.post-detail .scroll-top[data-v-09d5e1ca]{position:fixed;bottom:3rem;z-index:99;padding:.4rem 1.4rem;transform:translate(6rem)}.post-detail .close-btn[data-v-09d5e1ca]{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}
  26.  
  27. `
  28. let addStyle = document.createElement ("style");
  29. addStyle.rel = "stylesheet";
  30. addStyle.type = "text/css";
  31. addStyle.innerHTML = style
  32. document.head.append (addStyle)
  33.  
  34. setTimeout(function(){
  35.  
  36. (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 u of n.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).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}},r={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 w=(t,e)=>{const s=t.__vccOpts||t;for(const[a,o]of e)s[a]=o;return s},q={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(r.SHOW_MSG,{type:"warning",text:"请先登录!"});if(this.item.username===window.user.username)return l.emit(r.SHOW_MSG,{type:"warning",text:"不能感谢自己"});if(this.item.isThanked)return l.emit(r.SHOW_MSG,{type:"warning",text:"已经感谢过了"});if(confirm(`确认花费 10 个铜币向 @${this.item.username} 的这条回复发送感谢?`)){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(r.SHOW_MSG,{type:"error",text:e.message})),l.emit(r.REFRESH_ONCE,e.once)},e=>{this.$emit("recallThank"),l.emit(r.SHOW_MSG,{type:"error",text:"感谢失败"}),l.emit(r.REFRESH_ONCE)})}}}},Y=["fill","stroke"],X={class:"num"};function J(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((...u)=>n.thank&&n.thank(...u),["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,Y)],2))]),Vue.createElementVNode("div",X,Vue.toDisplayString(s.item.thankCount?s.item.thankCount:"感谢"),1)],2)}const M=w(q,[["render",J],["__scopeId","data-v-721ac04c"]]);const Q={name:"Author",components:{Point:M},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(r.ADD_TAG,this.comment.username)},removeTag(t){l.emit(r.REMOVE_TAG,{username:this.comment.username,tag:t})},checkIsLogin(t=""){return this.isLogin?(this.$emit(t),!0):(l.emit(r.SHOW_MSG,{type:"warning",text:"请先登录!"}),!1)},addThank(){l.emit(r.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"add"})},recallThank(){l.emit(r.CHANGE_COMMENT_THANK,{id:this.comment.id,type:"recall"})}}},x=t=>(Vue.pushScopeId("data-v-09f2f7fd"),t=t(),Vue.popScopeId(),t),ee={class:"Author-left"},te=x(()=>Vue.createElementVNode("path",{d:"M22 42H6V26",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),oe=x(()=>Vue.createElementVNode("path",{d:"M26 6H42V22",stroke:"#177EC9","stroke-width":"4","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)),ne=[te,oe],se=["href"],le=["src"],ie={class:"texts"},re=["href"],ae={key:0,class:"op"},ce={key:1,class:"mod"},ue={class:"ago"},de={class:"my-tag"},me=x(()=>Vue.createElementVNode("i",{class:"fa fa-tag"},null,-1)),pe=["onClick"],Ve={class:"Author-right"},he={class:"toolbar"},fe=Vue.createStaticVNode('<svg viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-09f2f7fd><path d="M4 6H44V36H29L24 41L19 36H4V6Z" fill="none" stroke="#929596" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-09f2f7fd></path><path d="M23 21H25.0025" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-09f2f7fd></path><path d="M33.001 21H34.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-09f2f7fd></path><path d="M13.001 21H14.9999" stroke="#929596" stroke-width="2" stroke-linecap="round" data-v-09f2f7fd></path></svg><span data-v-09f2f7fd>回复</span>',2),ge=[fe],ve=x(()=>Vue.createElementVNode("span",null,"隐藏",-1)),_e=[ve];function ke(t,e,s,a,o,n){const u=Vue.resolveComponent("Point");return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["Author",{expand:!s.modelValue}])},[Vue.createElementVNode("div",ee,[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"},ne)),Vue.createElementVNode("a",{class:"icon",href:`/member/${s.comment.username}`},[Vue.createElementVNode("img",{src:s.comment.avatar,alt:""},null,8,le)],8,se),Vue.createElementVNode("span",ie,[Vue.createElementVNode("strong",null,[Vue.createElementVNode("a",{href:`/member/${s.comment.username}`,class:"username"},Vue.toDisplayString(s.comment.username),9,re)]),s.comment.isOp?(Vue.openBlock(),Vue.createElementBlock("div",ae,"OP")):Vue.createCommentVNode("",!0),s.comment.isMod?(Vue.openBlock(),Vue.createElementBlock("div",ce,"MOD")):Vue.createCommentVNode("",!0),Vue.createElementVNode("span",ue,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",de,[me,Vue.createElementVNode("span",null,Vue.toDisplayString(m),1),Vue.createElementVNode("i",{class:"fa fa-trash-o remove",onClick:p=>n.removeTag(m)},null,8,pe)]))),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",Ve,[Vue.createElementVNode("div",he,[Vue.createElementVNode("div",{class:"tool",onClick:e[2]||(e[2]=m=>n.checkIsLogin("reply"))},ge),Vue.createElementVNode("div",{class:"tool",onClick:e[3]||(e[3]=m=>n.checkIsLogin("hide"))},_e),s.comment.thankCount?Vue.createCommentVNode("",!0):(Vue.openBlock(),Vue.createBlock(u,{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(u,{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((n.isDev?"a":"")+s.comment.floor),3)])],2)}const we=w(Q,[["render",ke],["__scopeId","data-v-09f2f7fd"]]);const ye=t=>(Vue.pushScopeId("data-v-0048db38"),t=t(),Vue.popScopeId(),t),Ee={class:"get-cursor"},Ce=["innerHTML"],Ne={class:"toolbar"},Te=ye(()=>Vue.createElementVNode("span",null,"请尽量让自己的回复能够对别人有帮助",-1)),xe={__name:"PostEditor",props:{replyUser:null,replyFloor:null,useType:{type:String,default(){return"reply-comment"}}},emits:["close"],setup(t,{emit:e}){const s=t,{replyUser:a,replyFloor:o,useType:n}=s,u=a?`@${a} #${o} `:"",m=Vue.inject("post");Vue.inject("show"),Vue.inject("pageType");const p=Vue.inject("allReplyUsers");let i=Vue.ref(!1);const V=Vue.ref(!1),c=Vue.ref("editorId_"+Date.now()),d=Vue.ref(u),_=Vue.ref(null),L=Vue.ref(null),G=Vue.ref('<span style="white-space:pre-wrap;"> </span>'),z=Vue.computed(()=>[n,i.value?"isFocus":""]),W=Vue.computed(()=>{var h;if(!_.value||!d.value)return"";let v=((h=_.value)==null?void 0:h.selectionStart)||0;return d.value.substring(0,v).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br/>").replace(/\s/g,G.value)}),H=Vue.computed(()=>d.value?d.value===u:!0);async function j(){if(H.value||V.value)return;V.value=!0;let v={thankCount:0,isThanked:!1,isOp:m.value.username===window.user.username,id:Date.now(),username:window.user.username,avatar:window.user.avatar,date:"几秒前",floor:m.value.replyCount+1,reply_content:d.value||Date.now(),children:[],replyUsers:a?[a]:[],replyFloor:o||-1},h=d.value.match(/@([\w]+?[\s])/g);h&&h.map(g=>{let f=g.replace("@","").replace(" ","");v.reply_content=v.reply_content.replace(f,`<a href="/member/${f}">${f}</a>`)});let k=`${window.baseUrl}/t/${m.value.id}`;$.post(k,{content:d.value,once:m.value.once}).then(g=>{V.value=!1;let f=g.search("你上一条回复的内容和这条相同");if(f>-1)return l.emit(r.SHOW_MSG,{type:"error",text:"你上一条回复的内容和这条相同"});if(f=g.search("请不要在每一个回复中都包括外链,这看起来像是在 spamming"),f>-1)return l.emit(r.SHOW_MSG,{type:"error",text:"请不要在每一个回复中都包括外链,这看起来像是在 spamming"});if(f=g.search("你上一条回复的内容和这条相同"),f>-1)return l.emit(r.SHOW_MSG,{type:"error",text:"你上一条回复的内容和这条相同"});if(g.search("创建新回复")>-1)return l.emit(r.REFRESH_ONCE,g),l.emit(r.SHOW_MSG,{type:"error",text:"回复失败"});d.value=u,e("close"),l.emit(r.REFRESH_ONCE,g),l.emit(r.SHOW_MSG,{type:"success",text:"回复成功"}),console.log("item",v),l.emit(r.ADD_REPLY,v)},g=>{V.value=!1,l.emit(r.SHOW_MSG,{type:"error",text:"回复失败"})})}function y(){l.emit(r.SHOW_CALL,{show:!1}),l.off(r.SET_CALL)}function O(){_.value.style.height=0,_.value.style.height=_.value.scrollHeight+"px"}function C(v){let h=L.value.getBoundingClientRect();l.emit(r.SHOW_CALL,{show:!0,top:h.top,left:h.left,text:v}),l.off(r.SET_CALL),l.on(r.SET_CALL,k=>{let g=_.value.selectionStart,f=d.value.slice(0,g),b=d.value.slice(g,d.value.length),K=f.lastIndexOf("@");f=d.value.slice(0,K+1),k==="管理员"&&(k="Livid @Kai @Olivia @GordianZ @sparanoid",setTimeout(O)),k==="所有人"&&(k=p.value.map((R,Z)=>Z?"@"+R:R).join(" "),setTimeout(O)),d.value=f+k+" "+b;let D=f.length+k.length+1;setTimeout(()=>{_.value.setSelectionRange(D,D)}),l.off(r.SET_CALL)})}function F(v){switch(v.keyCode){case 8:d.value==="@"&&y();break;case 37:case 38:case 39:case 40:setTimeout(()=>I({data:""}),100);break;case 27:return v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),!1}}function I(v){let h=_.value.selectionStart;if(d.value){if(v.data===" ")return y();if(v.data==="@"){if(d.value.length!==1){if(d.value[h-2]===" "||d.value[h-2]===`
  37. `)return C("")}else return C("");y()}else{let k=d.value.slice(0,h),g=k.lastIndexOf("@");if(g===-1)return y();let f=k.slice(g,h);if(f.includes(" "))y();else{if(g===0)return C(f.replace("@",""));if(d.value.length!==1){if(d.value[g-1]===" "||d.value[g-1]===`
  38. `)return C(f.replace("@",""))}else return C(f.replace("@",""));y()}}}}function U(){i.value=!1}return Vue.onMounted(()=>{$(`.${c.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"}),n==="reply-comment"&&_.value&&_.value.focus()}),Vue.onBeforeUnmount(()=>{$(`.${c.value}`).off()}),(v,h)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post-editor-wrapper",Vue.unref(z)])},[Vue.withDirectives(Vue.createElementVNode("textarea",{class:Vue.normalizeClass(["post-editor",c.value]),ref_key:"txtRef",ref:_,onFocus:h[0]||(h[0]=k=>Vue.isRef(i)?i.value=!0:i=!0),onBlur:U,onInput:I,onKeydown:F,"onUpdate:modelValue":h[1]||(h[1]=k=>d.value=k)},null,34),[[Vue.vModelText,d.value]]),Vue.createElementVNode("div",Ee,[Vue.createElementVNode("span",{innerHTML:Vue.unref(W)},null,8,Ce),Vue.createElementVNode("span",{class:"cursor",ref_key:"cursorRef",ref:L},"|",512)]),Vue.createElementVNode("div",Ne,[Te,Vue.createElementVNode("div",{class:Vue.normalizeClass(["button",{disabled:Vue.unref(H),loading:V.value}]),onClick:j},"回复 ",2)])],2))}},P=w(xe,[["__scopeId","data-v-0048db38"]]);const Se={key:0,class:"html-wrapper"},Be=["innerHTML"],be={__name:"BaseHtmlRender",props:["html"],setup(t){const e=t,s=Vue.inject("config"),a=Vue.ref(null),o=900,n=Vue.ref(!1),u=Vue.ref(!1);function m(i){let V=window.win().getSelection().toString();if(V){let c=V.match(/([A-Za-z0-9+/=]+)/g);if(c){if(c[0].length<4)return;l.emit(r.SHOW_TOOLTIP,{text:c[0],e:i})}}}Vue.watch(s.value,i=>{i.contentAutoCollapse||(n.value=!1)}),Vue.watch([()=>a.value,()=>e.html],()=>{!a.value||!e.html||s.value.contentAutoCollapse&&(a.value.querySelectorAll("img").forEach(i=>{i.removeEventListener("load",p),i.addEventListener("load",p)}),p())},{immediate:!0,flush:"post"});function p(){if(u.value)return;let i=a.value.getBoundingClientRect();n.value=i.height>=o}return(i,V)=>e.html?(Vue.openBlock(),Vue.createElementBlock("div",Se,[Vue.createElementVNode("div",{class:Vue.normalizeClass({mask:n.value})},[Vue.createElementVNode("div",Vue.mergeProps({ref_key:"contentRef",ref:a},i.$attrs,{innerHTML:e.html,onMouseup:m}),null,16,Be)],2),n.value?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"expand",onClick:V[0]||(V[0]=c=>{n.value=!1,u.value=!0})},"展开")):Vue.createCommentVNode("",!0)])):Vue.createCommentVNode("",!0)}},A=w(be,[["__scopeId","data-v-0bf60eab"]]);const Me={name:"Comment",components:{BaseHtmlRender:A,Author:we,PostEditor:P,Point:M},props:{modelValue:{reply_content:""}},data(){return{edit:!1,expand:!0,replyInfo:`@${this.modelValue.username} #${this.modelValue.floor} `,cssStyle:null}},inject:["post","postDetailWidth","show"],watch:{show(t){t&&(this.edit=!1)}},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(r.REMOVE,this.modelValue.floor),$.post(t).then(e=>{l.emit(r.REFRESH_ONCE),l.emit(r.SHOW_MSG,{type:"success",text:"隐藏成功"})},e=>{l.emit(r.SHOW_MSG,{type:"warning",text:"隐藏成功,仅本次有效(接口调用失败!)"})})},toggle(){this.expand=!this.expand}}},E=t=>(Vue.pushScopeId("data-v-55446f68"),t=t(),Vue.popScopeId(),t),Le={class:"comment-content"},He={class:"right"},Oe={class:"w"},Ie={key:0,class:"warning"},De=E(()=>Vue.createElementVNode("br",null,null,-1)),Re=E(()=>Vue.createElementVNode("br",null,null,-1)),Pe=E(()=>Vue.createElementVNode("br",null,null,-1)),Ae=E(()=>Vue.createElementVNode("br",null,null,-1)),Ge=E(()=>Vue.createElementVNode("br",null,null,-1)),ze=E(()=>Vue.createElementVNode("a",{href:"https://github.com/zyronon/v2ex-script/discussions/7",target:"_blank"},"这里",-1));function We(t,e,s,a,o,n){const u=Vue.resolveComponent("Author"),m=Vue.resolveComponent("BaseHtmlRender"),p=Vue.resolveComponent("PostEditor"),i=Vue.resolveComponent("Comment",!0);return Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["comment",s.modelValue.isOp?"op":""]),ref:"comment"},[Vue.createVNode(u,{modelValue:o.expand,"onUpdate:modelValue":e[0]||(e[0]=V=>o.expand=V),comment:s.modelValue,onReply:e[1]||(e[1]=V=>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]=V=>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]=V=>o.expand=!o.expand)}," 由于嵌套回复层级太深,自动将以下回复移至可见范围 ")):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",Le,[Vue.createElementVNode("div",{class:"left expand-line",onClick:e[4]||(e[4]=(...V)=>n.toggle&&n.toggle(...V))}),Vue.createElementVNode("div",He,[Vue.createElementVNode("div",Oe,[Vue.createVNode(m,{class:"text",html:s.modelValue.reply_content},null,8,["html"]),s.modelValue.isWrong?(Vue.openBlock(),Vue.createElementBlock("div",Ie,[Vue.createTextVNode(" 这条回复似乎有点问题,指定的楼层号与@的人对应不上 "),De,Vue.createTextVNode(" 原因可能有下面几种: "),Re,Vue.createTextVNode(" 一、屏蔽用户导致楼层塌陷:你屏蔽了A,自A以后的回复的楼层号都会减1 "),Pe,Vue.createTextVNode(" 二、忽略回复导致楼层塌陷:原理同上 "),Ae,Vue.createTextVNode(" 三、层主回复时指定错了楼层号(同一,层主屏蔽了别人,导致楼层塌陷) "),Ge,Vue.createTextVNode(" 四、脚本解析错误,请在"),ze,Vue.createTextVNode("反馈给 ")])):Vue.createCommentVNode("",!0),o.edit?(Vue.openBlock(),Vue.createBlock(p,{key:1,onClose:e[5]||(e[5]=V=>o.edit=!1),replyInfo:o.replyInfo,replyUser:s.modelValue.username,replyFloor:s.modelValue.floor},null,8,["replyInfo","replyUser","replyFloor"])):Vue.createCommentVNode("",!0)]),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(s.modelValue.children,(V,c)=>(Vue.openBlock(),Vue.createBlock(i,{modelValue:s.modelValue.children[c],"onUpdate:modelValue":d=>s.modelValue.children[c]=d,key:c},null,8,["modelValue","onUpdate:modelValue"]))),128))])]),o.cssStyle?(Vue.openBlock(),Vue.createElementBlock("div",{key:1,class:"more ago",onClick:e[6]||(e[6]=V=>o.expand=!o.expand)}," 由于嵌套回复层级太深,自动将以上回复移至可见范围 ")):Vue.createCommentVNode("",!0)],4),[[Vue.vShow,o.expand]])],2)}const je=w(Me,[["render",We],["__scopeId","data-v-55446f68"]]);const Fe={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(r.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}&amp;related=v2ex&amp;hashtags=apple&amp;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}&amp;related=v2ex&amp;hashtags=apple&amp;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(r.SHOW_MSG,{type:"success",text:this.post.isIgnore?"取消成功":"忽略成功"}),l.emit(r.MERGE,{isIgnore:!this.post.isIgnore})):l.emit(r.SHOW_MSG,{type:"warning",text:"忽略失败"}),this.loading2=!1):(this.post.isIgnore?this.loading2=!0:l.emit(r.IGNORE),(await window.win().fetch(t)).redirected?(this.post.isIgnore&&l.emit(r.REFRESH_ONCE),l.emit(r.SHOW_MSG,{type:"success",text:this.post.isIgnore?"取消成功":"忽略成功"}),l.emit(r.MERGE,{isIgnore:!this.post.isIgnore})):l.emit(r.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(r.MERGE,{collectCount:this.post.isFavorite?this.post.collectCount-1:this.post.collectCount+1}),l.emit(r.SHOW_MSG,{type:"success",text:this.post.isFavorite?"取消成功":"收藏成功"}),l.emit(r.REFRESH_ONCE,s),l.emit(r.MERGE,{isFavorite:!this.post.isFavorite});return}}l.emit(r.SHOW_MSG,{type:"error",text:"操作失败"})}}},N=t=>(Vue.pushScopeId("data-v-1f833fb4"),t=t(),Vue.popScopeId(),t),Ue={class:"toolbar"},$e=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),Ke=[$e],Ze={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},qe=["fill","stroke"],Ye={key:1,class:"tool no-hover"},Xe=N(()=>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)),Je=N(()=>Vue.createElementVNode("span",null,"Tweet",-1)),Qe=[Xe,Je],et={viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},tt=["fill","stroke"],ot=["fill","stroke"],nt=["fill","stroke"],st=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),lt=N(()=>Vue.createElementVNode("a",{target:"_blank",href:"https://github.com/zyronon/v2ex-script/issues"},"点击这里提一个Issue",-1)),it=N(()=>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)),rt=N(()=>Vue.createElementVNode("span",null,"脚本有问题?",-1));function at(t,e,s,a,o,n){return Vue.openBlock(),Vue.createElementBlock("div",Ue,[Vue.createElementVNode("div",{class:"tool",onClick:e[0]||(e[0]=u=>n.checkIsLogin("reply"))},Ke),n.post.once?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:Vue.normalizeClass(["tool",{loading:o.loading}]),onClick:e[1]||(e[1]=(...u)=>n.toggleFavorite&&n.toggleFavorite(...u))},[(Vue.openBlock(),Vue.createElementBlock("svg",Ze,[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,qe)])),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",Ye,[Vue.createElementVNode("span",null,Vue.toDisplayString(n.post.collectCount+"人收藏"),1)])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{class:"tool",onClick:e[2]||(e[2]=(...u)=>n.tweet&&n.tweet(...u))},Qe),n.post.once?(Vue.openBlock(),Vue.createElementBlock("div",{key:2,class:Vue.normalizeClass(["tool",{loading:o.loading2}]),onClick:e[3]||(e[3]=(...u)=>n.toggleIgnore&&n.toggleIgnore(...u))},[(Vue.openBlock(),Vue.createElementBlock("svg",et,[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,tt),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,ot),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,nt)])),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]=(...u)=>n.report&&n.report(...u))},[st,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]=(...u)=>n.showTooltipHandler&&n.showTooltipHandler(...u)),onMouseleave:e[8]||(e[8]=(...u)=>n.hideTooltip&&n.hideTooltip(...u))},[o.showTooltip?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:"tooltip",onMouseenter:e[5]||(e[5]=(...u)=>n.showTooltipHandler&&n.showTooltipHandler(...u)),onMouseleave:e[6]||(e[6]=(...u)=>n.hideTooltip&&n.hideTooltip(...u))},[Vue.createTextVNode(" 脚本有问题?"),lt],32)):Vue.createCommentVNode("",!0),it,rt],32)):Vue.createCommentVNode("",!0)])}const ct=w(Fe,[["render",at],["__scopeId","data-v-1f833fb4"]]);const ut={name:"detail",components:{Comment:je,PostEditor:P,Point:M,Toolbar:ct,BaseHtmlRender:A},inject:["allReplyUsers","post","isLogin","config","pageType"],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?["管理员","所有人"].concat(this.allReplyUsers).filter(t=>t.search(this.replyText)>-1):["管理员","所有人"].concat(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){pageType!=="post"&&(t?(window.win().doc.body.style.overflow="hidden",this.$nextTick(()=>{var e,s,a,o;(s=(e=this.$refs)==null?void 0:e.main)==null||s.focus(),(o=(a=this.$refs)==null?void 0:a.detail)==null||o.scrollTo({top:0})})):(window.win().doc.body.style.overflow="unset",this.isSticky=!1,(pageType==="home"||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(r.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(){window.win().removeEventListener("keydown",this.onKeyDown),l.off(r.SHOW_CALL)},methods:{close(t){this.pageType!=="post"&&(t==="space"?this.config.closePostDetailBySpace&&this.$emit("update:modelValue",!1):this.$emit("update:modelValue",!1))},setCall(t){l.emit(r.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(r.CHANGE_POST_THANK,{id:this.post.id,type:"add"})},recallThank(){l.emit(r.CHANGE_POST_THANK,{id:this.post.id,type:"recall"})},scrollTop(){this.$refs.detail.scrollTo({top:0,behavior:"smooth"})}}},S=t=>(Vue.pushScopeId("data-v-09d5e1ca"),t=t(),Vue.popScopeId(),t),dt={class:"main-wrapper"},mt={class:"my-box post-wrapper"},pt={class:"toolbar-wrapper"},Vt={key:0,class:"my-box comment-wrapper"},ht={key:0,class:"flex"},ft={class:"radio-group2"},gt={class:"my-cell flex"},vt={class:"gray"},_t={key:0},kt=S(()=>Vue.createElementVNode("strong",{class:"snow"},"•",-1)),wt=["innerHTML"],yt={key:1,class:"loading-wrapper"},Et={key:2,class:"comments",ref:"comments"},Ct={key:1,id:"no-comments-yet"},Nt={class:"my-cell flex"},Tt=S(()=>Vue.createElementVNode("span",null,"添加一条新回复",-1)),xt={class:"notice-right"},St={class:"w"},Bt=["onClick"],bt=S(()=>Vue.createElementVNode("i",{class:"fa fa-times","aria-hidden":"true"},null,-1)),Mt=[bt],Lt=S(()=>Vue.createElementVNode("i",{class:"fa fa-long-arrow-up","aria-hidden":"true"},null,-1)),Ht=[Lt];function Ot(t,e,s,a,o,n){const u=Vue.resolveComponent("BaseHtmlRender"),m=Vue.resolveComponent("Point"),p=Vue.resolveComponent("Toolbar"),i=Vue.resolveComponent("Comment"),V=Vue.resolveComponent("PostEditor");return Vue.withDirectives((Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post-detail",[s.isNight?"isNight":"",n.pageType]]),ref:"detail",onKeydown:e[11]||(e[11]=Vue.withKeys(c=>n.close(),["esc"])),onClick:e[12]||(e[12]=c=>n.close("space"))},[Vue.createElementVNode("div",{ref:"main",class:"main",tabindex:"1",onClick:e[10]||(e[10]=Vue.withModifiers(()=>{},["stop"]))},[Vue.createElementVNode("div",dt,[Vue.createElementVNode("div",mt,[s.modelValue?(Vue.openBlock(),Vue.createBlock(u,{key:0,html:n.post.headerTemplate},null,8,["html"])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",pt,[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(p,{onReply:e[0]||(e[0]=c=>o.isSticky=!o.isSticky)})])]),n.replies.length||s.loading?(Vue.openBlock(),Vue.createElementBlock("div",Vt,[n.config.showToolbar?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,class:Vue.normalizeClass(["my-cell flex",n.pageType!=="post"&&"flex-end"])},[n.pageType==="post"?(Vue.openBlock(),Vue.createElementBlock("div",ht,[Vue.createTextVNode(" 默认显示楼中楼: "),Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:n.config.autoOpenDetail}]),onClick:e[1]||(e[1]=c=>n.config.autoOpenDetail=!n.config.autoOpenDetail)},null,2)])):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",ft,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===0?"active":""]),onClick:e[2]||(e[2]=c=>n.changeOption(0))},"楼中楼 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===1?"active":""]),onClick:e[3]||(e[3]=c=>n.changeOption(1))},"感谢 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",s.displayType===2?"active":""]),onClick:e[4]||(e[4]=c=>n.changeOption(2))},"V2原版 ",2)])],2)):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",gt,[Vue.createElementVNode("span",vt,[Vue.createTextVNode(Vue.toDisplayString(n.post.replyCount)+" 条回复 ",1),n.post.createDate?(Vue.openBlock(),Vue.createElementBlock("span",_t,[Vue.createTextVNode("  "),kt,Vue.createTextVNode("  "+Vue.toDisplayString(n.post.createDate),1)])):Vue.createCommentVNode("",!0)]),Vue.createElementVNode("div",{class:"fr",innerHTML:n.post.fr},null,8,wt)]),s.loading?(Vue.openBlock(),Vue.createElementBlock("div",yt,[Vue.createElementVNode("div",{class:Vue.normalizeClass([s.isNight?"loading-b":"loading-c"])},null,2)])):(Vue.openBlock(),Vue.createElementBlock("div",Et,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(n.replies,(c,d)=>(Vue.openBlock(),Vue.createBlock(i,{key:c.floor,style:Vue.normalizeStyle(`border-bottom: 1px solid ${s.isNight?"#22303f":"#f2f2f2"}; padding: 1rem;margin-top: 0;`),modelValue:n.replies[d],"onUpdate:modelValue":_=>n.replies[d]=_},null,8,["style","modelValue","onUpdate:modelValue"]))),128))],512))])):(Vue.openBlock(),Vue.createElementBlock("div",Ct,"目前尚无回复")),n.isLogin?(Vue.openBlock(),Vue.createElementBlock("div",{key:2,class:Vue.normalizeClass(["my-box editor-wrapper",{sticky:o.isSticky}]),ref:"replyBox"},[Vue.createElementVNode("div",Nt,[Tt,Vue.createElementVNode("div",xt,[o.isSticky?(Vue.openBlock(),Vue.createElementBlock("a",{key:0,class:"float",onClick:e[5]||(e[5]=c=>o.isSticky=!1)},"取消回复框停靠")):Vue.createCommentVNode("",!0),Vue.createElementVNode("a",{onClick:e[6]||(e[6]=(...c)=>n.scrollTop&&n.scrollTop(...c))},"回到顶部")])]),Vue.createElementVNode("div",St,[s.modelValue?(Vue.openBlock(),Vue.createBlock(V,{key:0,useType:"reply-post",onClick:e[7]||(e[7]=c=>o.isSticky=!0)})):Vue.createCommentVNode("",!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),(c,d)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["call-item",{select:d===o.selectCallIndex}]),onClick:_=>n.setCall(c)},[Vue.createElementVNode("a",null,Vue.toDisplayString(c),1)],10,Bt))),256))],4)):Vue.createCommentVNode("",!0),n.config.closePostDetailBySpace?(Vue.openBlock(),Vue.createElementBlock("div",{key:1,class:"close-btn",onClick:e[8]||(e[8]=c=>n.close("btn"))},Mt)):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{class:"scroll-top button gray",onClick:e[9]||(e[9]=Vue.withModifiers((...c)=>n.scrollTop&&n.scrollTop(...c),["stop"]))},Ht)],512)],34)),[[Vue.vShow,s.modelValue]])}const It=w(ut,[["render",Ot],["__scopeId","data-v-09d5e1ca"]]);const Dt={class:"base-info"},Rt={class:"left"},Pt=["onClick","href"],At={class:"avatar"},Gt=["src"],zt={class:"right"},Wt={class:"title"},jt=["href"],Ft={class:"bottom"},Ut=["onClick","href"],$t=["onClick","href"],Kt={class:"date"},Zt={key:0,class:"count"},qt=["innerHTML"],Yt={__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(p=>{p.addEventListener("load",u)}),a.value=m.height>=s},{immediate:!0,flush:"post"});function u(){if(a.value)return;let m=o.value.getBoundingClientRect();a.value=m.height>=s}return(m,p)=>(Vue.openBlock(),Vue.createElementBlock("div",{class:Vue.normalizeClass(["post",[e.viewType,e.isNight?"isNight":""]]),style:Vue.normalizeStyle(Vue.unref(n)),onClick:p[0]||(p[0]=i=>m.$emit("show",i))},[Vue.createElementVNode("div",Dt,[Vue.createElementVNode("div",Rt,[Vue.createElementVNode("a",{onClick:Vue.withModifiers(i=>null,["stop"]),href:`/member/${e.post.username}`},[Vue.createElementVNode("div",At,[Vue.createElementVNode("img",{src:e.post.avatar,alt:""},null,8,Gt)])],8,Pt),Vue.createElementVNode("div",zt,[Vue.createElementVNode("div",Wt,[Vue.createElementVNode("a",{href:`t/${e.post.id}`},Vue.toDisplayString(e.post.title),9,jt)]),Vue.createElementVNode("div",Ft,[e.post.node?(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:0},[Vue.createElementVNode("a",{onClick:Vue.withModifiers(i=>null,["stop"]),href:e.post.nodeUrl,class:"my-node"},Vue.toDisplayString(e.post.node),9,Ut),Vue.createTextVNode("   •   ")],64)):Vue.createCommentVNode("",!0),Vue.createElementVNode("strong",null,[Vue.createElementVNode("a",{onClick:Vue.withModifiers(i=>null,["stop"]),class:"username",href:`/member/${e.post.username}`},Vue.toDisplayString(e.post.username),9,$t)]),Vue.createTextVNode("   •   "),Vue.createElementVNode("span",Kt,Vue.toDisplayString(e.post.date),1)])])]),e.post.replyCount?(Vue.openBlock(),Vue.createElementBlock("div",Zt,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,qt)],2)):Vue.createCommentVNode("",!0)],6))}},Xt=w(Yt,[["__scopeId","data-v-71df4ceb"]]),Jt={name:"Msg",props:{type:"",text:""},created(){setTimeout(()=>{this.$emit("close")},3e3)}},Qt=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),eo=[Qt],to={class:"right"};function oo(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]=u=>t.$emit("close"))},eo),Vue.createElementVNode("div",to,Vue.toDisplayString(s.text),1)],2)}const no=w(Jt,[["render",oo]]);const so=t=>(Vue.pushScopeId("data-v-2d42a498"),t=t(),Vue.popScopeId(),t),lo=so(()=>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)),io={key:1},ro={__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(r.SHOW_TOOLTIP,({text:i,e:V})=>{setTimeout(()=>s.value=!0),a.value=i,o.value="",n.left=V.clientX+"px",n.top=V.clientY+20+"px"}),window.win().addEventListener("click",i=>{e.value&&!e.value.contains(i.target)&&s.value&&(s.value=!1)},{capture:!0});const p=()=>s.value&&(s.value=!1);$(".post-detail",window.win().doc).on("scroll",p)});function u(){window.win().navigator.clipboard?(window.win().navigator.clipboard.writeText(o.value),l.emit(r.SHOW_MSG,{type:"success",text:"复制成功"})):l.emit(r.SHOW_MSG,{type:"error",text:"复制失败!浏览器不支持!"})}function m(){try{o.value=window.atob(a.value)}catch{l.emit(r.SHOW_MSG,{type:"error",text:"Base64解码失败!不是标准数据!"})}}return(p,i)=>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",io,[Vue.createElementVNode("span",null,Vue.toDisplayString(o.value),1),Vue.createElementVNode("div",{class:"button",onClick:u},"点击复制")])):(Vue.openBlock(),Vue.createElementBlock(Vue.Fragment,{key:0},[Vue.createTextVNode(" Base64解码:"+Vue.toDisplayString(a.value)+" ",1),lo],64))],4)),[[Vue.vShow,s.value]])}},ao=w(ro,[["__scopeId","data-v-2d42a498"]]);const co={name:"home",provide(){return{isDev:Vue.computed(()=>!1),isLogin:Vue.computed(()=>this.isLogin),pageType:Vue.computed(()=>this.pageType),tags:Vue.computed(()=>this.tags),show:Vue.computed(()=>this.show),post:Vue.computed(()=>this.current),config:Vue.computed(()=>this.config),allReplyUsers:Vue.computed(()=>{var t,e;return Array.from(new Set(((e=(t=this.current)==null?void 0:t.replies)==null?void 0:e.map(s=>s.username))??[]))})}},components:{PostDetail:It,Post:Xt,Msg:no,Base64Tooltip:ao},data(){return{loading:window.pageType==="post",loadMore:!1,isLogin:!!window.user.username,pageType:window.pageType,isNight:window.isNight,msgList:[],show:!1,showConfig:!1,current:window.clone(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,window.win().canParseV2exPage&&this.isList,$(window.win().doc).on("click","a",t=>{var o,n,u,m,p,i;let{href:e,id:s,title:a}=window.parse.parseA(t.currentTarget);if(s&&this.config.clickPostItemOpenDetail){let V=this.list.findIndex(d=>d.id==s),c=this.clone(window.initPost);if(V>-1?c=this.list[V]:c.title=a??"加载中",c.id=s,c.href=e,!c.headerTemplate){let d=`
  39. <div class="header">
  40. <div class="fr">
  41. <a href="/member/${((o=c==null?void 0:c.member)==null?void 0:o.username)??""}">
  42. <img src="${((n=c==null?void 0:c.member)==null?void 0:n.avatar_large)??""}" class="avatar"
  43. border="0"
  44. align="default" width="73" style="width: 73px; max-height: 73px;" alt="${((u=c==null?void 0:c.member)==null?void 0:u.username)??""}">
  45. </a>
  46. </div>
  47. <a href="/">V2EX</a> <span class="chevron">&nbsp;›&nbsp;</span> <a href="${((m=c==null?void 0:c.node)==null?void 0:m.url)??""}">${((p=c==null?void 0:c.node)==null?void 0:p.title)??""}</a>
  48. <div class="sep10"></div>
  49. <h1>${(c==null?void 0:c.title)||"加载中..."}</h1>
  50. <div id="topic_930514_votes" class="votes">
  51. <a href="javascript:" onclick="null" class="vote">
  52. <li class="fa fa-chevron-up"></li>
  53. &nbsp;
  54. </a> &nbsp;
  55. <a href="javascript:" onclick="null" class="vote">
  56. <li class="fa fa-chevron-down"></li>
  57. </a>
  58. </div> &nbsp;
  59. <small class="gray">
  60. <a href="/member/zyronon">${((i=c==null?void 0:c.member)==null?void 0:i.username)??""}</a> ·
  61. <span title="2023-04-07 11:32:28 +08:00">1 天前</span> · 0 次点击
  62. </small>
  63. </div>
  64. <div class="cell">
  65. <div class="topic_content">
  66. <div class="markdown_body">
  67. ${(c==null?void 0:c.content_rendered)??""}
  68. </div>
  69. </div>
  70. </div>
  71. `;c.headerTemplate=d}return this.getPostDetail(c),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:{showPost(){this.show=!0,$("#Wrapper #Main .box:lt(3)").each(function(){$(this).hide()})},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(r.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(r.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(this.current),this.clone(e)),this.config.autoOpenDetail&&this.showPost()),t==="postReplies"&&(this.current=Object.assign(this.clone(this.current),this.clone(e)),console.log("当前帖子",this.current),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(r.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(r.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(r.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(r.SHOW_MSG,t=>{this.msgList.push({...t,id:Date.now()})}),l.on(r.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(r.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(r.ADD_REPLY,t=>{this.current.replies.push(t)}),l.on(r.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(r.ADD_TAG,t=>{console.log("use",t),this.tagModal.currentUsername=t,this.tagModal.show=!0}),l.on(r.REMOVE_TAG,async({username:t,tag:e})=>{let s=this.clone(this.tags),a=this.tags[t]??[],o=a.findIndex(u=>u===e);o>-1&&a.splice(o,1),this.tags[t]=a,await window.parse.saveTags(this.tags)||(l.emit(r.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(r.SHOW_MSG,{type:"error",text:"主题未找到"}),this.loading=!1;if(a.redirected)return l.emit(r.SHOW_MSG,{type:"error",text:"没有权限"}),this.loading=!1;let o=await a.text();if(o.search("你要查看的页面需要先登录")>-1)return l.emit(r.SHOW_MSG,{type:"error",text:"你要查看的页面需要先登录"}),this.loading=!1;let u=o.match(/<body[^>]*>([\s\S]+?)<\/body>/g),m=$(u[0]);if(this.current=await window.parse.getPostDetail(this.current,m,o),this.current.replies.length){let p=this.list.findIndex(i=>i.id==t.id);p>-1?(this.list[p].replies=this.current.replies,this.list[p].nestedReplies=this.current.nestedReplies,this.list[p].once=this.current.once,this.list[p].createDate=this.current.createDate):this.list.push(this.clone(this.current))}this.loading=!1,console.log("当前帖子",this.current)}}},uo={key:0,class:"nav flex flex-end"},mo=Vue.createElementVNode("span",null,"设置",-1),po=[mo],Vo={class:"radio-group2"},ho={key:1,class:"my-box flex f14 open-post",style:{margin:"1rem 0 0 0",padding:"1rem"}},fo={class:"flex"},go={class:"msgs"},vo={key:1,class:"setting-modal modal"},_o={class:"wrapper"},ko=Vue.createElementVNode("div",{class:"title"}," 脚本设置 ",-1),wo=Vue.createElementVNode("div",{class:"sub-title"}," 设置自动保存到本地,下次打开依然生效 ",-1),yo={class:"option"},Eo=Vue.createElementVNode("span",null,"显示工具栏:",-1),Co=Vue.createElementVNode("div",{class:"notice"},[Vue.createElementVNode("div",null," 关闭此选项后,页面上所有的脚本工具栏和按钮,均不显示。 "),Vue.createElementVNode("div",null," 点击右上角插件“Tampermonkey”,找到“V2EX - 超级增强”脚本,找到“脚本设置”选项,点击可再次打开本弹框修改设置 ")],-1),No={class:"option"},To=Vue.createElementVNode("span",null,"列表帖子展示方式:",-1),xo={class:"radio-group2"},So={class:"option"},Bo=Vue.createElementVNode("span",null,"回复展示方式:",-1),bo={class:"radio-group2"},Mo={class:"option"},Lo=Vue.createElementVNode("span",null,"用户打标签:",-1),Ho={class:"option"},Oo=Vue.createElementVNode("span",null,"帖子界面默认显示楼中楼 :",-1),Io=Vue.createElementVNode("div",{class:"notice"}," 单独打开这种地址 https://v2ex.com/t/xxxx 时, 是否默认显示楼中楼 ",-1),Do={class:"option"},Ro=Vue.createElementVNode("span",null,"点击列表的帖子,打开详情弹框 :",-1),Po=Vue.createElementVNode("div",{class:"notice"}," 若关闭此项,点击列表的帖子时,不会打开弹框,会跳转网页 ",-1),Ao={class:"option"},Go=Vue.createElementVNode("span",null,"点击两侧空白处关闭帖子详情:",-1),zo={class:"option"},Wo=Vue.createElementVNode("span",null,"正文超长自动折叠:",-1),jo={class:"option"},Fo=Vue.createElementVNode("span",null,"列表hover时显示预览按钮:",-1),Uo=Vue.createElementVNode("div",{class:"notice"}," 此项需要刷新页面才能生效 ",-1),$o=Vue.createElementVNode("div",{class:"jieshao"}," 如只想要列表预览功能,可关闭 ”点击列表的帖子,打开详情弹框“,”帖子界面自动打开详情弹框“ ",-1),Ko={key:2,class:"tag-modal modal"},Zo={class:"wrapper"},qo=Vue.createElementVNode("div",{class:"title"}," 添加标签 ",-1),Yo={class:"option"},Xo=Vue.createElementVNode("span",null,"用户:",-1),Jo={class:"btns"};function Qo(t,e,s,a,o,n){const u=Vue.resolveComponent("PostDetail"),m=Vue.resolveComponent("Msg"),p=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",uo,[Vue.createElementVNode("div",{class:"nav-item",onClick:e[0]||(e[0]=i=>o.showConfig=!0)},po),Vue.createElementVNode("div",Vo,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="table"?"active":""]),onClick:e[1]||(e[1]=i=>o.config.viewType="table")},"表格 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="card"?"active":""]),onClick:e[2]||(e[2]=i=>o.config.viewType="card")},"卡片 ",2)])])):Vue.createCommentVNode("",!0),o.pageType==="post"&&!o.show?(Vue.openBlock(),Vue.createElementBlock("div",ho,[Vue.createElementVNode("div",fo,[Vue.createTextVNode(" 默认显示楼中楼 : "),Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.autoOpenDetail}]),onClick:e[3]||(e[3]=i=>o.config.autoOpenDetail=!o.config.autoOpenDetail)},null,2)]),Vue.createElementVNode("div",{class:Vue.normalizeClass(["button gray",{loading:o.loading}]),onClick:e[4]||(e[4]=(...i)=>n.showPost&&n.showPost(...i))}," 点击显示楼中楼 ",2)])):Vue.createCommentVNode("",!0)],64)):Vue.createCommentVNode("",!0),Vue.createVNode(u,{modelValue:o.show,"onUpdate:modelValue":e[5]||(e[5]=i=>o.show=i),isNight:o.isNight,displayType:o.config.commentDisplayType,"onUpdate:displayType":e[6]||(e[6]=i=>o.config.commentDisplayType=i),loading:o.loading},null,8,["modelValue","isNight","displayType","loading"]),Vue.createElementVNode("div",go,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(o.msgList,i=>(Vue.openBlock(),Vue.createBlock(m,{key:i.id,type:i.type,text:i.text,onClose:V=>n.removeMsg(i.id)},null,8,["type","text","onClose"]))),128))]),Vue.createVNode(p),o.showConfig?(Vue.openBlock(),Vue.createElementBlock("div",vo,[Vue.createElementVNode("div",{class:"mask",onClick:e[7]||(e[7]=i=>o.showConfig=!o.showConfig)}),Vue.createElementVNode("div",_o,[ko,wo,Vue.createElementVNode("div",yo,[Eo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.showToolbar}]),onClick:e[8]||(e[8]=i=>o.config.showToolbar=!o.config.showToolbar)},null,2)]),Co,Vue.createElementVNode("div",No,[To,Vue.createElementVNode("div",xo,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="table"?"active":""]),onClick:e[9]||(e[9]=i=>o.config.viewType="table")},"表格 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.viewType==="card"?"active":""]),onClick:e[10]||(e[10]=i=>o.config.viewType="card")},"卡片 ",2)])]),Vue.createElementVNode("div",So,[Bo,Vue.createElementVNode("div",bo,[Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===0?"active":""]),onClick:e[11]||(e[11]=i=>o.config.commentDisplayType=0)},"楼中楼 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===1?"active":""]),onClick:e[12]||(e[12]=i=>o.config.commentDisplayType=1)},"感谢最多 ",2),Vue.createElementVNode("div",{class:Vue.normalizeClass(["radio",o.config.commentDisplayType===2?"active":""]),onClick:e[13]||(e[13]=i=>o.config.commentDisplayType=2)},"V2原版 ",2)])]),Vue.createElementVNode("div",Mo,[Lo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.openTag}]),onClick:e[14]||(e[14]=i=>o.config.openTag=!o.config.openTag)},null,2)]),Vue.createElementVNode("div",Ho,[Oo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.autoOpenDetail}]),onClick:e[15]||(e[15]=i=>o.config.autoOpenDetail=!o.config.autoOpenDetail)},null,2)]),Io,Vue.createElementVNode("div",Do,[Ro,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.clickPostItemOpenDetail}]),onClick:e[16]||(e[16]=i=>o.config.clickPostItemOpenDetail=!o.config.clickPostItemOpenDetail)},null,2)]),Po,Vue.createElementVNode("div",Ao,[Go,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.closePostDetailBySpace}]),onClick:e[17]||(e[17]=i=>o.config.closePostDetailBySpace=!o.config.closePostDetailBySpace)},null,2)]),Vue.createElementVNode("div",zo,[Wo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.contentAutoCollapse}]),onClick:e[18]||(e[18]=i=>o.config.contentAutoCollapse=!o.config.contentAutoCollapse)},null,2)]),Vue.createElementVNode("div",jo,[Fo,Vue.createElementVNode("div",{class:Vue.normalizeClass(["switch",{active:o.config.showPreviewBtn}]),onClick:e[19]||(e[19]=i=>o.config.showPreviewBtn=!o.config.showPreviewBtn)},null,2)]),Uo,$o])])):Vue.createCommentVNode("",!0),o.tagModal.show?(Vue.openBlock(),Vue.createElementBlock("div",Ko,[Vue.createElementVNode("div",{class:"mask",onClick:e[20]||(e[20]=Vue.withModifiers(i=>o.tagModal.show=!1,["stop"]))}),Vue.createElementVNode("div",Zo,[qo,Vue.createElementVNode("div",Yo,[Xo,Vue.createElementVNode("div",null,Vue.toDisplayString(o.tagModal.currentUsername),1)]),Vue.withDirectives(Vue.createElementVNode("input",{type:"text",autofocus:"","onUpdate:modelValue":e[21]||(e[21]=i=>o.tagModal.tag=i),onKeydown:e[22]||(e[22]=Vue.withKeys((...i)=>n.addTag&&n.addTag(...i),["enter"]))},null,544),[[Vue.vModelText,o.tagModal.tag]]),Vue.createElementVNode("div",Jo,[Vue.createElementVNode("div",{class:"button info",onClick:e[23]||(e[23]=i=>o.tagModal.show=!1)},"取消"),Vue.createElementVNode("div",{class:"button",onClick:e[24]||(e[24]=(...i)=>n.addTag&&n.addTag(...i))},"确定")])])])):Vue.createCommentVNode("",!0)],2)}const en=w(co,[["render",Qo]]);let T;window.win().isFrame?T=$("#app",window.win().doc)[0]:T=window.win().query("#app");window.win().vue&&window.win().vue.unmount();let B=Vue.createApp(en);window.win().vue=B;window.win().appNode=T;B.config.unwrapInjectedRef=!0;B.config.errorHandler=(t,e,s)=>{console.error("通过vue errorHandler捕获的错误"),console.error(t),console.error(e),console.error(s)};B.mount(T);
  72. //# sourceMappingURL=index-21b77f78.js.map
  73.  
  74.  
  75.  
  76. })
  77.  
  78.  
  79.  
  80.  
  81. const isDev = false
  82.  
  83. if (!isDev) {
  84. window.onerror = function (message, source, lineno, colno, error) {
  85. console.log('捕获到异常:', {message, source, lineno, colno, error});
  86. }
  87. window.addEventListener('error', (error) => {
  88. console.log('捕获到异常:', error);
  89. }, true)
  90. window.addEventListener("unhandledrejection", function (e) {
  91. e.preventDefault()
  92. console.log('捕获到异常:', e);
  93. return true;
  94. });
  95. }
  96.  
  97. if (window.top !== window.self) {
  98. window.win = () => window.top
  99. // window.baseUrl = 'https://www.v2ex.com'
  100. window.baseUrl = window.top.location.origin
  101. window.win().isFrame = true
  102. //直接使用v2的jquery,因为v2对jquery作了修改,加了一些header,缺少这些header发送请求会报403
  103. window.$ = window.win().$
  104. } else {
  105. window.win = () => window
  106. //这里必须一致。不然会报跨域
  107. window.baseUrl = location.origin
  108. window.win().isFrame = false
  109. }
  110.  
  111. window.initPost = {
  112. replies: [],
  113. nestedReplies: [],
  114. username: '',
  115. member: {},
  116. node: {},
  117. headerTemplate: '',
  118. title: '',
  119. id: '',
  120. type: 'post',
  121. once: '',
  122. replyCount: 0,
  123. clickCount: 0,
  124. thankCount: 0,
  125. collectCount: 0,
  126. isFavorite: false,
  127. isIgnore: false,
  128. isThanked: false,
  129. isReport: false,
  130. }
  131. window.win().doc = window.win().document
  132. window.win().query = (v) => window.win().document.querySelector(v)
  133. window.clone = (val) => JSON.parse(JSON.stringify(val))
  134. window.user = {
  135. tagPrefix: '--用户标签--',
  136. tags: {},
  137. username: '',
  138. avatar: '',
  139. tagsId: ''
  140. }
  141. window.pageType = ''
  142. window.pageData = {pageNo: 1}
  143. window.config = {
  144. showToolbar: true,
  145. showPreviewBtn: true,
  146. autoOpenDetail: true,
  147. openTag: true,
  148. clickPostItemOpenDetail: true,
  149. // newTabOpen: true,
  150. closePostDetailBySpace: true,//点击空白处关闭详情
  151. contentAutoCollapse: true,//点击空白处关闭详情
  152. viewType: 'card',
  153. commentDisplayType: 0
  154. }
  155. window.isNight = $('.Night').length === 1
  156. window.cb = null
  157. window.postList = []
  158. window.parse = {
  159. //解析帖子内容
  160. async parsePostContent(post = {}, body, htmlText) {
  161. let once = htmlText.match(/var once = "([\d]+)";/)
  162. // console.log(once)
  163. if (once && once[1]) {
  164. post.once = once[1]
  165. }
  166.  
  167. post.isReport = htmlText.includes('你已对本主题进行了报告')
  168.  
  169. let topic_buttons = body.find('.topic_buttons')
  170. if (topic_buttons.length) {
  171. let favoriteNode = topic_buttons.find('.tb:first')
  172. if (favoriteNode.length) {
  173. post.isFavorite = favoriteNode[0].innerText === '取消收藏'
  174. }
  175. let ignoreNode = topic_buttons.find('.tb:nth-child(3)')
  176. if (ignoreNode.length) {
  177. post.isIgnore = ignoreNode[0].innerText === '取消忽略'
  178. }
  179. //
  180. let thankNode = topic_buttons.find('#topic_thank .tb')
  181. if (!thankNode.length) {
  182. post.isThanked = true
  183. }
  184.  
  185. let topic_stats = topic_buttons.find('.topic_stats')
  186. //topic_stats = $(`<div class="fr topic_stats" style="padding-top: 4px;">9569 次点击 &nbsp;∙&nbsp; 28 人收藏 &nbsp; ∙&nbsp; 1 人感谢 &nbsp; </div>`)
  187. //收藏数、感谢数
  188. if (topic_stats.length) {
  189. let text = topic_stats[0].innerText
  190. let reg1 = text.matchAll(/([\d]+)[\s]*人收藏/g)
  191. let collectCountReg = [...reg1]
  192. if (collectCountReg.length) {
  193. post.collectCount = Number(collectCountReg[0][1])
  194. }
  195. // console.log([...collectCountReg])
  196. let reg2 = text.matchAll(/([\d]+)[\s]*人感谢/g)
  197. let thankCountReg = [...reg2]
  198. if (thankCountReg.length) {
  199. post.thankCount = Number(thankCountReg[0][1])
  200. }
  201. let reg3 = text.matchAll(/([\d]+)[\s]*次点击/g)
  202. let clickCountReg = [...reg3]
  203. if (clickCountReg.length) {
  204. post.clickCount = Number(clickCountReg[0][1])
  205. }
  206. // console.log([...thankCountReg])
  207. }
  208. }
  209.  
  210. // console.log('基本信息', post)
  211.  
  212. let header = body.find('#Main .box').first()
  213. let temp = header.clone()
  214. temp.find('.topic_buttons').remove()
  215.  
  216. post.headerTemplate = `${temp.html()} `
  217. return post
  218. },
  219. //获取帖子所有回复
  220. async getPostAllReplies(post = {}, body, htmlText, pageNo = 1) {
  221. if (body.find('#no-comments-yet').length) {
  222. return post
  223. }
  224.  
  225. let box = body.find('#Main > .box')[1]
  226. let cells = box.querySelectorAll('.cell')
  227. post.fr = cells[0].querySelector('.cell .fr').innerHTML
  228. cells = Array.from(cells)
  229.  
  230. //获取创建时间
  231. let snow = cells[0].querySelector('.snow')
  232. post.createDate = snow?.nextSibling.nodeValue.trim() || ''
  233.  
  234. let repliesMap = []
  235. if (cells[1].id) {
  236. repliesMap.push({i: pageNo, replyList: this.parsePageReplies(cells.slice(1))})
  237. let replies = this.getAllReply(repliesMap)
  238. post.replies = replies
  239. post.replyCount = replies.length
  240. post.allReplyUsers = Array.from(new Set(replies.map(v => v.username)))
  241. let nestedList = this.createNestedList(replies, post.allReplyUsers)
  242. if (nestedList) post.nestedReplies = nestedList
  243. return post
  244. } else {
  245. let promiseList = []
  246. // console.log(this.current.repliesMap)
  247. return new Promise((resolve, reject) => {
  248. repliesMap.push({i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1))})
  249.  
  250. let pages = cells[1].querySelectorAll('a')
  251. pages = Array.from(pages)
  252. // console.log(pages)
  253. let url = window.baseUrl + '/t/' + post.id
  254. for (let i = 0; i < pages.length; i++) {
  255. let currentPageNo = Number(pages[i].innerText)
  256. if (currentPageNo == pageNo) continue
  257. promiseList.push(this.fetchPostOtherPageReplies(url + '?p=' + currentPageNo, currentPageNo))
  258. }
  259. Promise.allSettled(promiseList).then(
  260. (results) => {
  261. results.filter((result) => result.status === "fulfilled").map(v => repliesMap.push(v.value))
  262. let replies = this.getAllReply(repliesMap)
  263. post.replies = replies
  264. post.replyCount = replies.length
  265. post.allReplyUsers = Array.from(new Set(replies.map(v => v.username)))
  266. let nestedList = this.createNestedList(replies, post.allReplyUsers)
  267. if (nestedList) post.nestedReplies = nestedList
  268. resolve(post)
  269. }
  270. );
  271. })
  272. }
  273. },
  274. //请求帖子其他页的回复
  275. fetchPostOtherPageReplies(url, pageNo) {
  276. return new Promise(resolve => {
  277. $.get(url).then(res => {
  278. let s = res.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
  279. let box = $(s[0]).find('#Main .box')[1]
  280. let cells = box.querySelectorAll('.cell')
  281. cells = Array.from(cells)
  282. resolve({i: pageNo, replyList: this.parsePageReplies(cells.slice(2, cells.length - 1))})
  283. })
  284. })
  285. },
  286. //解析页面的回复
  287. parsePageReplies(nodes) {
  288. let replyList = []
  289. nodes.forEach((node, index) => {
  290. if (!node.id) return
  291. let item = {
  292. thankCount: 0,
  293. isThanked: false,
  294. isOp: false,
  295. id: node.id.replace('r_', '')
  296. }
  297. let reply_content = node.querySelector('.reply_content')
  298. // console.log('reply_content',reply_content)
  299. item.reply_content = reply_content.innerHTML
  300. item.reply_text = reply_content.innerText
  301.  
  302. let {users, floor} = this.parseReplyContent(item.reply_content)
  303. item.replyUsers = users
  304. item.replyFloor = floor
  305. if (index === 5) {
  306. // console.log(item)
  307. // console.log(reply_content.innerText)
  308. // console.log(reply_content.innerHTML)
  309. }
  310. let ago = node.querySelector('.ago')
  311. item.date = ago.innerText
  312.  
  313. let userNode = node.querySelector('strong a')
  314. item.username = userNode.innerText
  315. let avatar = node.querySelector('td img')
  316. item.avatar = avatar.src
  317. let no = node.querySelector('.no')
  318. item.floor = Number(no.innerText)
  319.  
  320. let thank_area = node.querySelector('.thank_area')
  321. if (thank_area) {
  322. item.isThanked = thank_area.classList.contains('thanked')
  323. }
  324. let small = node.querySelector('.small')
  325. if (small) {
  326. item.thankCount = Number(small.innerText)
  327. }
  328. let op = node.querySelector('.op')
  329. if (op) {
  330. item.isOp = true
  331. }
  332. let mod = node.querySelector('.mod')
  333. if (mod) {
  334. item.isMod = true
  335. }
  336. // console.log('item', item)
  337.  
  338. replyList.push(item)
  339. })
  340. return replyList
  341. },
  342. //解析回复内容,解析出@用户,回复楼层。用于后续生成嵌套楼层
  343. parseReplyContent(str) {
  344. if (!str) return
  345. let users = []
  346. let getUsername = (userStr) => {
  347. let endIndex = userStr.indexOf('">')
  348. if (endIndex > -1) {
  349. let user = userStr.substring(0, endIndex)
  350. if (!users.find(i => i === user)) {
  351. users.push(user)
  352. }
  353. }
  354. }
  355. // str = `@<a hr a> #4 @<a1 href="/member/Eiden1">Eiden1</a1> @<a href="/member/Eiden111">Eiden21</a> #11 这也是执行阶段,所谓的安装也是程序业务的 setup 。<br>windows 、Android 并没有系统级的 CD-KEY 。`
  356. let userReg = /@<a href="\/member\/([\s\S]+?)<\/a>/g
  357. let has = str.matchAll(userReg)
  358. let res2 = [...has]
  359. // console.log('总匹配', res2)
  360. if (res2.length > 1) {
  361. res2.map(item => {
  362. getUsername(item[1])
  363. })
  364. }
  365. if (res2.length === 1) {
  366. getUsername(res2[0][1])
  367. }
  368. // console.log('用户', users)
  369. // console.log('楼层', floor)
  370. let floor = -1
  371. //只有@一个人的时候才去查找是否指定楼层号。
  372. if (users.length === 1) {
  373. let floorReg = /@<a href="\/member\/[\s\S]+?<\/a>[\s]+#([\d]+)/g
  374. let hasFloor = str.matchAll(floorReg)
  375. let res = [...hasFloor]
  376. // console.log('总匹配', res)
  377. if (res.length) {
  378. floor = Number(res[0][1])
  379. }
  380. }
  381. return {users, floor}
  382. },
  383. //获取帖子详情
  384. async getPostDetail(post = {}, body, htmlText, pageNo = 1) {
  385. post = await this.parsePostContent(post, body, htmlText)
  386. return await this.getPostAllReplies(post, body, htmlText, pageNo)
  387. },
  388. getAllReply(repliesMap = []) {
  389. return repliesMap.sort((a, b) => a.i - b.i).reduce((pre, i) => {
  390. pre = pre.concat(i.replyList)
  391. return pre
  392. }, [])
  393. },
  394. //生成嵌套回复
  395. createNestedList(allList = []) {
  396. if (!allList.length) return []
  397. if ((Date.now() - window.win().lastCallDate) < 1000) {
  398. // console.log('短时间内,重复调用,因为监听了replies,所以打开时会触发两次。第二次不管他')
  399. return false
  400. }
  401. // console.log('cal-createNestedList', Date.now())
  402.  
  403. let list = JSON.parse(JSON.stringify(allList))
  404. let nestedList = []
  405. list.map((item, index) => {
  406. let startList = list.slice(0, index)
  407. //用于918489这种情况,@不存在的人
  408. let startReplyUsers = Array.from(new Set(startList.map(v => v.username)))
  409.  
  410. let endList = list.slice(index + 1)
  411.  
  412. item.level = 0
  413. if (index === 0) {
  414. nestedList.push(this.findChildren(item, endList, list))
  415. } else {
  416. if (!item.isUse) {
  417. //是否是一级回复
  418. let isOneLevelReply = false
  419. if (item.replyUsers.length) {
  420. if (item.replyUsers.length > 1) {
  421. isOneLevelReply = true
  422. } else {
  423. isOneLevelReply = !startReplyUsers.find(v => v === item.replyUsers[0]);
  424. }
  425. } else {
  426. isOneLevelReply = true
  427. }
  428. if (isOneLevelReply) {
  429. item.level === 0
  430. nestedList.push(this.findChildren(item, endList, list))
  431. }
  432. }
  433. }
  434. })
  435. // console.log('replies长度', allList)
  436. // console.log('nestedList长度', nestedList)
  437. window.win().lastCallDate = Date.now()
  438. return nestedList
  439. },
  440. //查找子回复
  441. findChildren(item, endList, all) {
  442. const fn = (child, endList2, parent,) => {
  443. child.level = parent.level + 1
  444. let rIndex = all.findIndex(v => v.floor === child.floor)
  445. if (rIndex > -1) {
  446. all[rIndex].isUse = true
  447. }
  448. parent.children.push(this.findChildren(child, endList2, all,))
  449. }
  450. // console.log('endList', endList)
  451. item.children = []
  452. // if (item.floor === 46) debugger
  453. let floorReplyList = []
  454.  
  455. //先找到指定楼层的回复,再去循环查找子回复
  456. //原因:问题930155,有图
  457. for (let i = 0; i < endList.length; i++) {
  458. let currentItem = endList[i]
  459. //如果已被使用,直接跳过
  460. if (currentItem.isUse) continue
  461. if (currentItem.replyFloor === item.floor) {
  462. //必须楼层对应的名字和@人的名字相同。因为经常出现不相同的情况
  463. if (currentItem.replyUsers.length === 1 && currentItem.replyUsers[0] === item.username) {
  464. //先标记为使用,不然遇到“问题930155”,会出现重复回复
  465. currentItem.isUse = true
  466. floorReplyList.push({endList: endList.slice(i + 1), currentItem})
  467. //问题930155:这里不能直接找子级,如果item为A,currentItem为B,但随后A又回复了B,然后C回复A。这样直接找子级就会把C归类到B的子回复,而不是直接A的子回复
  468. //截图:930155.png
  469. // fn(currentItem, endList.slice(i + 1), item)
  470. } else {
  471. currentItem.isWrong = true
  472. }
  473. }
  474. }
  475. //从后往前找
  476. //原因:问题933080,有图
  477. floorReplyList.reverse().map(({currentItem, endList}) => {
  478. fn(currentItem, endList, item)
  479. })
  480.  
  481. //下一个我的下标,如果有下一个我,那么当前item的子回复应在当前和下个我的区间内查找
  482. let nextMeIndex = endList.findIndex(v => {
  483. //必须是下一个不是”自己回复自己“的自己
  484. //原因:问题887644(1-2),有图
  485. return (v.username === item.username) && (v.replyUsers?.[0] !== item.username)
  486. })
  487. let findList = nextMeIndex > -1 ? endList.slice(0, nextMeIndex) : endList
  488.  
  489. for (let i = 0; i < findList.length; i++) {
  490. let currentItem = findList[i]
  491. //如果已被使用,直接跳过
  492. if (currentItem.isUse) continue
  493. if (currentItem.replyUsers.length === 1) {
  494. //如果这条数据指定了楼层,并且名字也能匹配上,那么直接忽略
  495. //原因:问题887644-3,有图
  496. if (currentItem.replyFloor !== -1) {
  497. if (all[currentItem.replyFloor].username === currentItem.username) {
  498. continue
  499. }
  500. }
  501. let endList2 = endList.slice(i + 1)
  502. //如果是下一条是同一人的回复,那么跳出循环
  503. if (currentItem.username === item.username) {
  504. //自己回复自己的特殊情况
  505. if (currentItem.replyUsers[0] === item.username) {
  506. fn(currentItem, endList2, item)
  507. }
  508. break
  509. } else {
  510. if (currentItem.replyUsers[0] === item.username) {
  511. fn(currentItem, endList2, item)
  512. }
  513. }
  514. } else {
  515. //下一条是同一人的回复,并且均未@人。直接跳过
  516. if (currentItem.username === item.username) break
  517. }
  518. }
  519.  
  520. //排序,因为指定楼层时,是从后往前找的
  521. item.children = item.children.sort((a, b) => a.floor - b.floor)
  522. return item
  523. },
  524. //解析其他页面
  525. parseOtherPage(html, pageType) {
  526. let bodyText = html.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
  527. let body = $(bodyText[0])
  528.  
  529. if (pageType === 'recent') {
  530. let list = body.find('.item')
  531. let res = this.parsePagePostList(Array.from(list))
  532. let page = body.find('.cell:last').html()
  533. return {...res, page}
  534. }
  535. if (pageType === 'nodePage') {
  536. let topics = body.find('#TopicsNode')
  537. let list = topics.children()
  538. let res = this.parsePagePostList(Array.from(list))
  539. let page = topics.next().html()
  540. return {...res, page}
  541. }
  542. },
  543. //解析页面帖子列表
  544. parsePagePostList(list, box) {
  545. list.forEach(itemDom => {
  546. let item = window.clone(window.initPost)
  547. let item_title = itemDom.querySelector('.item_title a')
  548. let {href, id} = window.parse.parseA(item_title)
  549. item.id = id
  550. item.href = href
  551. item.url = window.win().location.origin + '/api/topics/show.json?id=' + item.id
  552. itemDom.classList.add('post-item')
  553. itemDom.classList.add(`id_${id}`)
  554. window.postList.push(item)
  555. })
  556.  
  557. Promise.allSettled(window.postList.map(item => $.get(item.url))).then(res => {
  558. let ok = res.filter((r) => r.status === "fulfilled").map(v => v.value[0])
  559. // let fail = res.filter((r) => r.status === "rejected")
  560.  
  561. box.style.boxShadow = 'unset'
  562. box.style.background = 'unset'
  563. if (window.config.viewType === 'card') {
  564. list.forEach(itemDom => {
  565. itemDom.classList.add('preview')
  566. })
  567. }
  568. ok.map(postItem => {
  569. if (postItem?.id) {
  570. let itemDom = box.querySelector(`.id_${postItem.id}`)
  571.  
  572. if (window.config.showPreviewBtn) {
  573. //添加切换按钮
  574. let td = itemDom.querySelector('td:nth-child(4)')
  575. td.style.position = 'relative'
  576. let toggle = document.createElement('div')
  577. toggle.dataset['id'] = postItem.id
  578. toggle.classList.add('toggle')
  579. toggle.innerText = '点击展开/收起'
  580. td.append(toggle)
  581. }
  582.  
  583. let index = window.postList.findIndex(v => v.id == postItem.id)
  584. if (index > -1) {
  585. let obj = window.postList[index]
  586. window.postList[index] = Object.assign({}, obj, postItem)
  587.  
  588. if (postItem.content_rendered) {
  589. let a = document.createElement('a')
  590. a.href = obj.href
  591. a.classList.add('post-content')
  592. let div = document.createElement('div')
  593. div.innerHTML = postItem.content_rendered
  594. a.append(div)
  595. // console.log(div.clientHeight)
  596. itemDom.append(a)
  597. }
  598. }
  599. }
  600. })
  601. cbChecker({type: 'syncData'})
  602. })
  603. },
  604. parseA(a) {
  605. let href = a.href
  606. let id
  607. if (href.includes('/t/')) {
  608. if (href.includes('#')) {
  609. id = href.substring(href.indexOf('/t/') + 3, href.indexOf('#'))
  610. } else {
  611. id = href.substring(href.indexOf('/t/') + 3,)
  612. }
  613. }
  614. return {href, id, title: a.innerText}
  615. },
  616. //创建记事本里面的tag标签
  617. async createTagNote() {
  618. let data = new FormData()
  619. data.append('content', '--用户标签--')
  620. data.append('parent_id', 0)
  621. data.append('syntax', 0)
  622. let apiRes = await window.win().fetch(`${window.baseUrl}/notes/new`, {method: 'post', body: data})
  623. console.log(apiRes)
  624. if (apiRes.redirected && apiRes.status === 200) {
  625. //成功
  626. return apiRes.url.substr(-5)
  627. }
  628. return null
  629. },
  630. //标签操作
  631. async saveTags(val) {
  632. let data = new FormData()
  633. data.append('content', window.user.tagPrefix + JSON.stringify(val))
  634. data.append('syntax', 0)
  635. let apiRes = await window.win().fetch(`${window.baseUrl}/notes/edit/${window.user.tagsId}`, {
  636. method: 'post', body: data
  637. })
  638. return apiRes.redirected && apiRes.status === 200;
  639. }
  640. }
  641.  
  642. async function sleep(time) {
  643. return new Promise(resolve => {
  644. // console.log('等待vue加载完成,第' + count + '次', Date.now())
  645. setTimeout(resolve, time)
  646. })
  647. }
  648.  
  649. async function cbChecker(val, count = 0) {
  650. if (window.cb) {
  651. window.cb(val)
  652. } else {
  653. while ((!window.cb) && count < 20) {
  654. await sleep(500)
  655. count++
  656. }
  657. window.cb && window.cb(val)
  658. }
  659. }
  660.  
  661. //初始化脚本菜单
  662. function initMonkeyMenu() {
  663. try {
  664. GM_registerMenuCommand("脚本设置", function (event) {
  665. cbChecker({type: 'openSetting'})
  666. });
  667. GM_registerMenuCommand('💬 反馈 & 建议', function () {
  668. GM_openInTab('https://github.com/zyronon/v2ex-script/issues', {
  669. active: true,
  670. insert: true,
  671. setParent: true
  672. });
  673. });
  674. } catch (e) {
  675. console.error('无法使用Tampermonkey')
  676. }
  677. }
  678.  
  679. //初始化样式表
  680. function initStyle() {
  681. //给Wrapper和content取消宽高,是因为好像是v2的屏蔽机制,时不时会v2会修复这两个div的宽高,让网页变形
  682. let style2 = `
  683. html, body {
  684. font-size: 62.5%;
  685. }
  686.  
  687. #Wrapper {
  688. height: unset !important;
  689. width: unset !important;
  690. }
  691.  
  692. #Wrapper > .content {
  693. height: unset !important;
  694. width: unset !important;
  695. }
  696.  
  697.  
  698. .post-item {
  699. background: white;
  700. }
  701.  
  702. .post-item > .post-content {
  703. height: 0;
  704. margin-top: 0;
  705. }
  706.  
  707. .post-item:hover .toggle {
  708. display: flex;
  709. }
  710.  
  711. .toggle {
  712. position: absolute;
  713. right: 0;
  714. top: 0.5rem;
  715. width: 8rem;
  716. height: 100%;
  717. display: flex;
  718. justify-content: flex-end;
  719. align-items: flex-end;
  720. cursor: pointer;
  721. font-size: 1.2rem;
  722. color: #ccc;
  723. display: none;
  724. }
  725.  
  726. .preview {
  727. margin: 1rem 0;
  728. border: 1px solid #e2e2e2;
  729. border-radius: 0.4rem;
  730. cursor: pointer;
  731. }
  732.  
  733. .preview:hover {
  734. border: 1px solid #968b8b;
  735. }
  736.  
  737. .preview > .post-content {
  738. height: unset !important;
  739. margin-top: 0.5rem !important;
  740. }
  741.  
  742. .post-content {
  743. margin-top: 0.5rem;
  744. display: block;
  745. max-height: 20rem;
  746. overflow: hidden;
  747. text-decoration: unset !important;
  748. line-break: anywhere;
  749. }
  750.  
  751. .post-content:link {
  752. color: black;
  753. }
  754.  
  755. .post-content:visited {
  756. color: #afb9c1 !important;
  757. }
  758.  
  759. .Night .post-item {
  760. background: #18222d !important;
  761. }
  762.  
  763. .Night .preview {
  764. border: 1px solid #3b536e;
  765. }
  766.  
  767. .Night .preview > .post-content:link {
  768. color: #d1d5d9;
  769. }
  770.  
  771. .Night .preview > .post-content:visited {
  772. color: #393f4e !important;
  773. }
  774.  
  775. `
  776. let addStyle2 = document.createElement("style");
  777. addStyle2.rel = "stylesheet";
  778. addStyle2.type = "text/css";
  779. addStyle2.innerHTML = style2
  780. $(window.win().doc.head).append(addStyle2)
  781. }
  782.  
  783. initMonkeyMenu()
  784. initStyle()
  785.  
  786. window.win().canParseV2exPage = true
  787. if (window.win().canParseV2exPage) {
  788. let location2 = window.win().location
  789. if (location2.pathname === '/') {
  790. window.pageType = 'home'
  791. } else if (location2.href.match(/.com\/?tab=/)) {
  792. window.pageType = 'home'
  793. } else if (location2.href.match(/.com\/go\//)) {
  794. if (!location2.href.includes('/links')) {
  795. window.pageType = 'nodePage'
  796. }
  797. } else if (location2.href.match(/.com\/recent/)) {
  798. window.pageType = 'recent'
  799. } else {
  800. let r = location2.href.match(/.com\/t\/([\d]+)/)
  801. if (r) {
  802. window.pageType = 'post'
  803. window.pageData.id = r[1]
  804. if (location2.search) {
  805. let pr = location2.href.match(/\?p=([\d]+)/)
  806. if (pr) window.pageData.pageNo = Number(pr[1])
  807. }
  808. }
  809. }
  810.  
  811. let top2 = window.win().query('.tools .top:nth-child(2)').text
  812. if (top2 !== '注册') {
  813. window.user.username = top2
  814. window.user.avatar = $('#Rightbar .box .avatar', window.win().doc).attr('src')
  815. cbChecker({type: 'syncData'})
  816.  
  817. //获取或创建记事本的标签
  818. $.get(window.baseUrl + '/notes').then(r => {
  819. let bodyText = r.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
  820. let body = $(bodyText[0])
  821. let items = body.find('#Main .box .note_item_title a')
  822. let needCreateNoteTags = true
  823. if (items.length) {
  824. let tags = Array.from(items).find(v => v.innerText.includes(window.user.tagPrefix))
  825. if (tags) {
  826. needCreateNoteTags = false
  827. window.user.tagsId = tags.href.substr(-5)
  828. cbChecker({type: 'syncData'})
  829. $.get(window.baseUrl + '/notes/edit/' + window.user.tagsId).then(r2 => {
  830. bodyText = r2.match(/<body[^>]*>([\s\S]+?)<\/body>/g)
  831. body = $(bodyText[0])
  832. let text = body.find('.note_editor').text()
  833. if (text === window.user.tagPrefix) {
  834. window.user.tags = {}
  835. } else {
  836. let tagJson = text.substring(window.user.tagPrefix.length)
  837. try {
  838. window.user.tags = JSON.parse(tagJson)
  839. } catch (e) {
  840. console.log('tage', tagJson)
  841. window.user.tags = {}
  842. }
  843. }
  844. cbChecker({type: 'syncData'})
  845. })
  846. }
  847. }
  848. if (needCreateNoteTags) {
  849. window.parse.createTagNote().then(r => {
  850. if (r) {
  851. window.user.tagsId = r
  852. window.user.tags = {}
  853. cbChecker({type: 'syncData'})
  854. }
  855. })
  856. }
  857. })
  858. }
  859.  
  860. //获取默认配置
  861. let configStr = window.win().localStorage.getItem('v2ex-config')
  862. if (configStr) {
  863. let configObj = JSON.parse(configStr)
  864. configObj = configObj[window.user.username ?? 'default']
  865. if (configObj) {
  866. window.config = Object.assign(window.config, configObj)
  867. }
  868. }
  869.  
  870. let $section = document.createElement('section')
  871. $section.id = 'app'
  872.  
  873. let box
  874. let list
  875. switch (window.pageType) {
  876. case 'nodePage':
  877. box = window.win().doc.querySelectorAll('#Wrapper #Main .box')
  878. let topics = box[1].querySelector('#TopicsNode')
  879. list = topics.querySelectorAll('.cell')
  880. list[0].before($section)
  881. window.parse.parsePagePostList(list, box[1])
  882. break
  883. case 'recent':
  884. case 'home':
  885. box = window.win().query('#Wrapper #Main .box')
  886. list = box.querySelectorAll('.item')
  887. list[0].before($section)
  888. window.parse.parsePagePostList(list, box)
  889. break
  890. case 'post':
  891. box = window.win().query('#Wrapper #Main .box')
  892. box.after($section)
  893. window.parse.parsePostContent(
  894. {id: window.pageData.id},
  895. $(window.win().doc.body),
  896. window.win().doc.documentElement.outerHTML
  897. ).then(async res => {
  898. // console.log('详情页-基本信息解析完成', new Date())
  899. window.pageData.post = res
  900. await cbChecker({type: 'postContent', value: res}, 0)
  901. })
  902.  
  903. window.parse.getPostAllReplies(
  904. {id: window.pageData.id},
  905. $(window.win().doc.body),
  906. window.win().doc.documentElement.outerHTML,
  907. window.pageData.pageNo
  908. ).then(async res => {
  909. // console.log('详情页-回复解析完成', new Date())
  910. window.pageData.post = Object.assign(window.pageData.post, res)
  911. await cbChecker({type: 'postReplies', value: res}, 0)
  912. })
  913. break
  914. default:
  915. console.error('未知页面')
  916. break
  917. }
  918. }
  919.  
  920.  
  921.  
  922.  
  923. })();