// ==UserScript== // @name 拷贝漫画PC显示评论 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 改自Byaidu的拷贝漫画增强插件,只保留评论的加载和发送功能,并重做了ui // @author ljw2487 // @match *://*.copymanga.com/* // @match *://*.copymanga.org/* // @match *://*.copymanga.net/* // @match *://*.copymanga.info/* // @match *://*.copymanga.site/* // @match *://*.copymanga.tv/* // @match *://copymanga.com/* // @match *://copymanga.org/* // @match *://copymanga.net/* // @match *://copymanga.info/* // @match *://copymanga.site/* // @match *://copymanga.tv/* // @license GNU General Public License v3.0 or later // @resource element_css https://unpkg.com/element-ui@2.15.0/lib/theme-chalk/index.css // @resource animate_css https://unpkg.com/animate.css@4.1.1/animate.min.css // @require https://unpkg.com/vue@2.6.12/dist/vue.min.js // @require https://unpkg.com/element-ui@2.15.0/lib/index.js // @require https://unpkg.com/axios@0.27.2/dist/axios.min.js // @require https://unpkg.com/store.js@1.0.4/store.js // @require https://unpkg.com/jquery@3.5.1/dist/jquery.min.js // @require https://unpkg.com/jszip@3.1.5/dist/jszip.min.js // @require https://unpkg.com/file-saver@2.0.5/dist/FileSaver.min.js // @require https://unpkg.com/crypto-js@4.1.1/crypto-js.js // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_xmlhttpRequest // @run-at document-start // @downloadURL none // ==/UserScript== // retry 拦截器 axios.interceptors.response.use(undefined, (err) => { return new Promise((resolve)=>{setTimeout(()=>{resolve()},1000)}).then(() => axios(err.config)); }); function route() { console.log('LOAD SUCCESSED', window.document.title) // /comic/gengjuesezhuanshengtaiguotoule/chapter/bf86c68c-195a-11ec-943d-00163e0ca5bd if (/^\/comic\/.*\/.*$/.test(location.pathname)) comicPage(1) else if (/^\/h5\/comicContent\/.*\/.*$/.test(location.pathname)) comicPage(0) } route() /////////////////////////////////////////////////////////////////////// async function loadCSS(){ var element_css, animate_css; if (typeof(GM_getResourceText)=='undefined'){ await axios.get('https://unpkg.com/element-ui@2.15.0/lib/theme-chalk/index.css') .then(function (response) { element_css = response.data; }) await axios.get('https://unpkg.com/animate.css@4.1.1/animate.min.css') .then(function (response) { animate_css = response.data; }) }else{ element_css = GM_getResourceText("element_css"); animate_css = GM_getResourceText("animate_css"); } GM_addStyle(element_css); GM_addStyle(animate_css); } ///////////////////////////////////////////////////////////////////// async function comicPage(isPC) { loadCSS() var comic, chapter, htmlBody, newDiv, newStyle if (isPC) comic = window.location.pathname.split('/')[2] else comic = window.location.pathname.split('/')[3] chapter = window.location.pathname.split('/')[4] // console.log('Comic:', comic,'|| Chapter:', chapter) // htmlBody = document.getElementsByTagName('body')[0] console.log(htmlBody) newDiv = document.createElement('div') newDiv.innerHTML = `
查看评论
发表
` newStyle = document.createElement('style') newStyle.innerHTML = ` ` // htmlBody.appendChild(newDiv) htmlBody.appendChild(newStyle) // var app = new Vue({ el: '#app', data: { comment_data: [], // 评论数据源 comment_input: '', showComment: true, elementKey: 0, }, computed: { }, mounted () { // window.vuethis = this // console.log(window.vuethis) }, methods: { send_comment: async function () { let token = await cookieStore.get('token'); await axios.post( 'https://api.copymanga.net/api/v3/member/roast', 'chapter_id=' + chapter + '&roast=' + this.comment_input + '&_update=true', { headers: { 'authorization': 'Token ' + token.value } }).then(function (response) { app.comment_input = response.data.message; console.log('评论成功:', response.data) }); await this.load_comment(); }, load_comment: async function () { await axios.get('https://api.copymanga.site/api/v3/roasts?chapter_id=' + chapter + '&limit=100&offset=0&_update=true') .then(function (response) { let list = response.data.results.list app.comment_data = list // 控制台展示评论 // console.log('↓↓↓↓评论列表↓↓↓↓') // for (var i = 0; i < list.length; i++) { // console.log(list[i].user_name, ' : ', list[i].comment) // } // console.log('↑↑↑↑评论列表↑↑↑↑') // console.log('评论请发送:app.send_comment(评论内容)') }) }, } }); app.load_comment() }