回复消息脚本

· · 个人记录

// ==UserScript==
// @name         NFLSOJ Comment Helper
// @namespace    none
// @version      0.0.7
// @description  NFLSOJ Comment Helper
// @author       Allen123456hello
// @license      GPL-3.0-or-later
// @match        http://www.nfls.com.cn:20035/article/*
// @match        http://nflsoi.cc:20035/article/*
// @match        http://192.168.188.77/article/*
// @icon         http://www.nfls.com.cn:10611/favicon.ico
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    const cur=window.location.pathname.split('/');
    var id=undefined;
    for (let i=cur.length-1;i;--i){if ((i^1)&&(cur[i-1]=='article')){id=cur[i];break;}else if (cur[i]!=''){break;}}
    console.log(id);
    if (id=="0"||id==undefined){return;}
    const replyhtml=`<form class="ui reply form" method="post" action="/article/${id}/comment"><div class="field"><textarea name="comment" class="markdown-edit"></textarea></div><div style="text-align: center; "><button id="submit_button" type="submit" class="ui labeled submit icon button"><i class="icon edit"></i> 回复</button></div></form>`;
    if (id){document.querySelector(".padding").insertAdjacentHTML("beforeend",replyhtml);}else{console.log("Unknown Error");}
})();