diff --git a/NGA_BBS_plugins/MobileSupport/MobileSupport.user.js b/NGA_BBS_plugins/MobileSupport/MobileSupport.user.js new file mode 100644 index 0000000..9a87a3d --- /dev/null +++ b/NGA_BBS_plugins/MobileSupport/MobileSupport.user.js @@ -0,0 +1,72 @@ +// ==UserScript== +// @name NGA优化摸鱼体验插件-移动端支持 +// @namespace https://github.com/lifegpc/userscript +// @version 1.0.0 +// @author lifegpc +// @description 支持移动端页面 +// @license MIT +// @match *://bbs.nga.cn/* +// @match *://ngabbs.com/* +// @match *://nga.178.com/* +// @match *://g.nga.cn/* +// @grant unsafeWindow +// @run-at document-start +// @inject-into content +// ==/UserScript== + +(function (registerPlugin) { + 'use strict'; + const MobileSupport = { + name: 'MobileSupport', + title: '移动端支持', + desc: '支持移动端页面', + settings: [{ + key: 'showPostReadingRecord', + title: '显示帖子浏览记录标记', + default: false + }], + buttons: [], + beforeSaveSettingFunc(settings) { + console.log(settings); + const postReadingRecord = this.mainScript.getModule('PostReadingRecord'); + if (!postReadingRecord && settings['showPostReadingRecord']) { + return '请先安装帖子浏览记录插件'; + } + console.log(postReadingRecord); + }, + initFunc() { + if (typeof this.pluginSettings['showPostReadingRecord'] === 'string') { + this.pluginSettings['showPostReadingRecord'] = false; + } + }, + async renderThreadsFunc($el) { + if (this.pluginSettings['showPostReadingRecord']) { + const postReadingRecord = this.mainScript.getModule('PostReadingRecord'); + if (postReadingRecord) { + const markStyle = `color: ${postReadingRecord.pluginSettings['markColor']}; opacity: ${parseInt(postReadingRecord.pluginSettings['markOpacity']) / 100};` + const $a = $el.find('.c2 .replies'); + const tid = this.mainScript.getModule('AuthorMark').getQueryString('tid', $a.attr('href')) + const currentCount = parseInt($a.text()) + const record = await postReadingRecord.store.getItem(tid) + const recordCount = record?.lastReadCount || -1 + if (record) { + $el.find('.c2 > a').attr('style', markStyle) + } + if (postReadingRecord.pluginSettings['replyCountEnable'] && recordCount > -1 && currentCount > recordCount) { + $el.find('.c2 > span[id^=t_pc]').append(`${currentCount-recordCount}`) + } + postReadingRecord.currentThread[tid] = {currentCount} + } + } + }, + async renderFormsFunc($el) { + }, + style: `` + } + registerPlugin(MobileSupport) + +})(function(plugin) { + plugin.meta = GM_info.script + unsafeWindow.ngaScriptPlugins = unsafeWindow.ngaScriptPlugins || [] + unsafeWindow.ngaScriptPlugins.push(plugin) +});