// ==UserScript== // @name NGA优化摸鱼体验 // @namespace https://github.com/kisshang1993/NGA-BBS-Script // @version 3.9.5 // @author HLD // @description NGA论坛显示优化,功能增强,防止突然蹦出一对??而导致的突然性的社会死亡 // @license MIT // @require https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js // @require https://cdn.staticfile.org/spectrum/1.8.0/spectrum.js // @require https://greasyfork.org/scripts/424901-nga-script-resource/code/NGA-Script-Resource.js?version=926265 // @icon https://i.loli.net/2021/04/07/8x3yFj2pWEKluSY.png // @match *://bbs.nga.cn/* // @match *://ngabbs.com/* // @match *://nga.178.com/* // @grant GM_registerMenuCommand // @inject-into content // @downloadURL none // ==/UserScript== (function () { 'use strict'; /** * NGA摸鱼主脚本 * @class NGABBSScript * @constructor */ class NGABBSScript { constructor () { // 配置 this.setting = { normal: {}, advanced: {} } // 模块 this.modules = [] // 样式 this.style = '' } /** * 获取模块对象 * @method getModule * @param {String} name 模块name * @return {Object} 模块对象 */ getModule (name) { for (const m of this.modules) { if (m.name && m.name === name) { return m } } return null } /** * 全程渲染函数 * @method renderAlways */ renderAlways() { for (const module of this.modules) { try { module.renderAlwaysFunc && module.renderAlwaysFunc(this) } catch (error) { this.printLog(`[${module.name}]模块在[renderAlwaysFunc()]中运行失败!`) console.log(error) } } } /** * 列表页渲染函数 * @method renderThreads */ renderThreads () { $('.topicrow[hld-threads-render!=ok]').each((index, dom) => { const $el = $(dom) for (const module of this.modules) { try { module.renderThreadsFunc && module.renderThreadsFunc($el, this) } catch (error) { this.printLog(`[${module.name}]模块在[renderThreadsFunc()]中运行失败!`) console.log(error) } } $el.attr('hld-threads-render', 'ok') }) } /** * 详情页渲染函数 * @method renderForms */ renderForms () { $('.forumbox.postbox[hld-forms-render!=ok]').each((index, dom) => { const $el = $(dom) // 等待NGA页面渲染完成 if ($el.find('.small_colored_text_btn').length == 0) return true for (const module of this.modules) { try { module.renderFormsFunc && module.renderFormsFunc($el, this) } catch (error) { this.printLog(`[${module.name}]模块在[renderFormsFunc()]中运行失败!`) console.log(error) } } $el.attr('hld-forms-render', 'ok') }) } /** * 添加模块 * @method addModule * @param {Object} module 模块对象 * @param {Boolean} plugin 是否为插件 */ addModule (module, plugin=false) { // 组件预处理函数 if (module.beforeFunc) { try { module.beforeFunc(this) } catch (error) { this.printLog(`[${module.name}]模块在[beforeFunc()]中运行失败!`) console.log(error) } } // 添加模块 const addModule = setting => { if (setting.shortCutCode && this.setting.normal.shortcutKeys) this.setting.normal.shortcutKeys.push(setting.shortCutCode) if (setting.key) { this.setting[setting.type || 'normal'][setting.key] = setting.default } } // 功能板块 if (module.setting && !Array.isArray(module.setting)) { addModule(module.setting) } if (module.settings && Array.isArray(module.settings)) { for (const setting of module.settings) { addModule(setting) } } // 添加样式 if (module.style) { this.style += module.style } plugin && (module.type = 'plugin') this.modules.push(module) } /** * 判断当前页面是否为列表页 * @method isThreads * @return {Boolean} 判断状态 */ isThreads () { return $('#m_threads').length > 0 } /** * 判断当前页面是否为详情页 * @method isForms * @return {Boolean} 判断状态 */ isForms () { return $('#m_posts').length > 0 } /** * 抛出异常 * @method throwError * @param {String} msg 异常信息 */ throwError (msg) { alert(msg) throw(msg) } /** * 初始化 * @method init */ init () { // 开始初始化 this.printLog('初始化...') const startInitTime = new Date().getTime() const modulesTable = [] //同步配置 this.loadSetting() // 组件初始化函数 for (const module of this.modules) { if (module.initFunc) { try { module.initFunc(this) } catch (error) { this.printLog(`[${module.name}]模块在[initFunc()]中运行失败!`) console.log(error) } } } // 组件后处理函数 for (const module of this.modules) { if (module.afterFunc) { try { module.afterFunc(this) } catch (error) { this.printLog(`[${module.name}]模块在[afterFunc()]中运行失败!`) console.log(error) } } } // 异步样式 for (const module of this.modules) { if (module.asyncStyle) { try { this.style += module.asyncStyle(this) } catch (error) { this.printLog(`[${module.name}]模块在[asyncStyle()]中运行失败!`) console.log(error) } } modulesTable.push({ name: module.title || module.name || 'UNKNOW', type: module.type == 'plugin' ? '插件' : '内置模块', version: module.version || '-' }) } // 插入样式 const style = document.createElement("style") style.appendChild(document.createTextNode(this.style)) document.getElementsByTagName('head')[0].appendChild(style) // 初始化完成 const endInitTime = new Date().getTime() console.table(modulesTable) this.printLog(`[v${this.getInfo().version}] 初始化完成:共加载${this.modules.length}个模块,总耗时${endInitTime-startInitTime}ms`) } /** * 通知弹框 * @method popNotification * @param {String} msg 消息内容 * @param {Number} duration 显示市场(ms) */ popNotification (msg, duration=1000) { $('#hld__noti_container').length == 0 && $('body').append('
') let $msgBox = $(`
${msg}
`) $('#hld__noti_container').append($msgBox) $msgBox.slideDown(100) setTimeout(() => { $msgBox.fadeOut(500) }, duration) setTimeout(() => { $msgBox.remove() }, duration + 500) } /** * 消息弹框 * @method popMsg * @param {String} msg 消息内容 * @param {String} type 消息类型 [ok, err, warn] */ popMsg(msg, type='ok') { $('.hld__msg').length > 0 && $('.hld__msg').remove() let $msg = $(`
${msg}
`) $('body').append($msg) $msg.slideDown(200) setTimeout(() => { $msg.fadeOut(500) }, type == 'ok' ? 2000 : 5000) setTimeout(() => { $msg.remove() }, type == 'ok' ? 2500 : 5500) } /** * 打印控制台消息 * @method printLog * @param {String} msg 消息内容 */ printLog (msg) { console.log(`%cNGA%cScript%c ${msg}`, 'background: #222;color: #fff;font-weight:bold;padding:2px 2px 2px 4px;border-radius:4px 0 0 4px;', 'background: #fe9a00;color: #000;font-weight:bold;padding:2px 4px 2px 2px;border-radius:0px 4px 4px 0px;', 'background:none;color:#000;' ) } /** * 保存配置到本地 * @method saveSetting * @param {String} msg 自定义消息信息 */ saveSetting (msg='保存配置成功,刷新页面生效') { for (let k in this.setting.normal) { $('input#hld__cb_' + k).length > 0 && (this.setting.normal[k] = $('input#hld__cb_' + k)[0].checked) } window.localStorage.setItem('hld__NGA_setting', JSON.stringify(this.setting.normal)) for (let k in this.setting.advanced) { if ($('#hld__adv_' + k).length > 0) { const valueType = typeof this.setting.advanced[k] const inputType = $('#hld__adv_' + k)[0].nodeName if (inputType == 'SELECT') { this.setting.advanced[k] = $('#hld__adv_' + k).val() } else { if (valueType == 'boolean') { this.setting.advanced[k] = $('#hld__adv_' + k)[0].checked } if (valueType == 'number') { this.setting.advanced[k] = +$('#hld__adv_' + k).val() } if (valueType == 'string') { this.setting.advanced[k] = $('#hld__adv_' + k).val() } } } } window.localStorage.setItem('hld__NGA_advanced_setting', JSON.stringify(this.setting.advanced)) msg && this.popMsg(msg) } /** * 从本地读取配置 * @method loadSetting */ loadSetting () { // 基础设置 try { if (window.localStorage.getItem('hld__NGA_setting')) { let localSetting = JSON.parse(window.localStorage.getItem('hld__NGA_setting')) for (let k in this.setting.normal) { !localSetting.hasOwnProperty(k) && (localSetting[k] = this.setting.normal[k]) if (k == 'shortcutKeys') { if (localSetting[k].length < this.setting.normal[k].length) { const offset_count = this.setting.normal[k].length - localSetting[k].length localSetting[k] = localSetting[k].concat(this.setting.normal[k].slice(-offset_count)) } // 更改默认按键 let index = 0 for (const module of this.modules) { if (module.setting && module.setting.shortCutCode) { if (localSetting[k][index] != module.setting.shortCutCode) { module.setting.rewriteShortCutCode = localSetting[k][index] } index += 1 }else if (module.settings) { for (const setting of module.settings) { if (setting.shortCutCode) { if (localSetting[k][index] != setting.shortCutCode) { setting.rewriteShortCutCode = localSetting[k][index] } index += 1 } } } } } } for (let k in localSetting) { !this.setting.normal.hasOwnProperty(k) && delete localSetting[k] } this.setting.normal = localSetting } // 高级设置 if (window.localStorage.getItem('hld__NGA_advanced_setting')) { let localAdvancedSetting = JSON.parse(window.localStorage.getItem('hld__NGA_advanced_setting')) for (let k in this.setting.advanced) { !localAdvancedSetting.hasOwnProperty(k) && (localAdvancedSetting[k] = this.setting.advanced[k]) } for (let k in localAdvancedSetting) { !this.setting.advanced.hasOwnProperty(k) && delete localAdvancedSetting[k] } this.setting.advanced = localAdvancedSetting } } catch { this.throwError('【NGA-Script】配置文件出现错误,无法加载配置文件!\n遇到此问题请清空浏览器缓存并重新刷新页面\n如还有问题,请前往脚本发布页提出反馈') } } /** * 检查是否更新 * @method checkUpdate */ checkUpdate() { // 字符串版本转数字 const vstr2num = str => { let num = 0 str.split('.').forEach((n, i) => num += i < 2 ? +n * 1000 / Math.pow(10, i) : +n) return num } // 字符串中版本截取 const vstr2mid = str => { return str.substring(0, str.lastIndexOf('.')) } //检查更新 if (window.localStorage.getItem('hld__NGA_version')) { const local_version = vstr2num(window.localStorage.getItem('hld__NGA_version')) const current_version = vstr2num(GM_info.script.version) if (current_version > local_version) { const lv_mid = +vstr2mid(window.localStorage.getItem('hld__NGA_version')) const cv_mid = +vstr2mid(GM_info.script.version) if (cv_mid > lv_mid) { const focus = '' $('body').append(`

×NGA-Script已更新至v${GM_info.script.version}

${focus}

查看更新内容

`) $('body').on('click', '#hld__updated a', function () { $(this).parents('#hld__updated').remove() window.localStorage.setItem('hld__NGA_version', GM_info.script.version) }) } else { window.localStorage.setItem('hld__NGA_version', GM_info.script.version) } } } else window.localStorage.setItem('hld__NGA_version', GM_info.script.version) } /** * 运行脚本 * @method run */ run() { this.checkUpdate() this.init() setInterval(() => { this.renderAlways() this.isThreads() && this.renderThreads() this.isForms() && this.renderForms() }, 100) } /** * 获取脚本信息 * @method getInfo * @return {Object} 脚本信息对象 */ getInfo() { return { version: GM_info.script.version, author: 'HLD', github: 'https://github.com/kisshang1993/NGA-BBS-Script', update: 'https://greasyfork.org/zh-CN/scripts/393991-nga%E4%BC%98%E5%8C%96%E6%91%B8%E9%B1%BC%E4%BD%93%E9%AA%8C' } } } /* 注册菜单按钮 */ try { // 设置面板 GM_registerMenuCommand('设置面板', function () { $('#hld__setting_cover').css('display', 'flex') }) // 修复脚本 GM_registerMenuCommand('修复脚本', function () { if (window.confirm('如脚本运行失败或无效,尝试修复脚本,这会清除脚本的本地缓存信息\n* 本地缓存信息包含配置,各种名单等\n* 此操作不可逆转,如果需要备份,请手动备份localStorage内的hld__*的字段\n\n继续请点击【确定】')) { for (let i=0;i
×

NGA优化摸鱼插件v${script.getInfo().version}

显示优化

功能增强

高级设置

鼠标停留在选项文字上可以显示详细描述,设置有误可能会导致插件异常或者无效!

`) const insertDom = setting => { if (setting.type === 'normal') { $panelDom.find(`#hld__normal_${setting.menu || 'left'}`).append(`

`) if (setting.extra) { $panelDom.find(`#hld__cb_${setting.key}`).attr('enable', `hld__${setting.key}_${setting.extra.mode || 'fold'}`) $panelDom.find(`#hld__normal_${setting.menu || 'left'}`).append(`

`) } } if (setting.type === 'advanced') { let formItem = '' const valueType = typeof setting.default if (valueType === 'boolean') { formItem = `` } if (valueType === 'number') { formItem = `` } if (valueType === 'string') { if (setting.options) { let t = '' for (const option of setting.options) { t += `` } formItem = `` } else { formItem = `` } } $panelDom.find(`#hld__advanced_${setting.menu || 'left'}`).append(` ${setting.title || setting.key} ${formItem} `) } } for (const module of script.modules) { if (module.setting && module.setting.key) { insertDom(module.setting) } if (module.settings) { for (const setting of module.settings) { setting.key && insertDom(setting) } } } /** * Bind:Mouseover Mouseout * 提示信息Tips */ $panelDom.find('.hld__adv-help').mouseover(function(e){ const $help = $(`
${$(this).attr('help').replace(/\n/g, '
')}
`) $help.css({ top: ($(this).offset().top + $(this).height() + 5) + 'px', left: $(this).offset().left + 'px' }) $('body').append($help) }).mouseout(()=>$('.hld__help-tips').remove()) $('body').append($panelDom) //本地恢复设置 //基础设置 for (let k in script.setting.normal) { if ($('#hld__cb_' + k).length > 0) { $('#hld__cb_' + k)[0].checked = script.setting.normal[k] const enableDomID = $('#hld__cb_' + k).attr('enable') if (enableDomID) { script.setting.normal[k] ? $('#' + enableDomID).show() : $('#' + enableDomID).hide() $('#' + enableDomID).find('input').each(function () { $(this).val() == script.setting.normal[$(this).attr('name').substr(8)] && ($(this)[0].checked = true) }) $('#hld__cb_' + k).on('click', function () { $(this)[0].checked ? $('#' + enableDomID).slideDown() : $('#' + enableDomID).slideUp() }) } } } //高级设置 for (let k in script.setting.advanced) { if ($('#hld__adv_' + k).length > 0) { const valueType = typeof script.setting.advanced[k] if (valueType == 'boolean') { $('#hld__adv_' + k)[0].checked = script.setting.advanced[k] } if (valueType == 'number' || valueType == 'string') { $('#hld__adv_' + k).val(script.setting.advanced[k]) } } } /** * Bind:Click * 设置面板-展开切换高级设置 */ $('body').on('click', '#hld__advanced_button', function () { if ($('.hld__advanced-setting-panel').is(':hidden')) { $('.hld__advanced-setting-panel').css('display', 'flex') $(this).text('-') } else { $('.hld__advanced-setting-panel').css('display', 'none') $(this).text('+') } }) /** * Bind:Click * 关闭面板(通用) */ $('body').on('click', '.hld__list-panel .hld__setting-close', function () { $(this).parent().remove() }) /** * Bind:Click * 保存配置 */ $('body').on('click', '#hld__save__data', () => { script.saveSetting() $('#hld__setting_cover').fadeOut(200) }) }, renderAlwaysFunc: function () { if($('.hld__setting-box').length == 0) { $('#startmenu > tbody > tr > td.last').append('
') let $entry = $('NGA优化摸鱼插件设置') $entry.click(()=>$('#hld__setting_cover').css('display', 'flex')) $('#hld__setting_close').click(()=>$('#hld__setting_cover').fadeOut(200)) $('.hld__setting-box').append($entry) } }, addButton: function (button) { $('#hld_setting_panel_buttons').append(` `) }, style: ` #hld__setting {color:#6666CC;cursor:pointer;} #hld__setting_cover {display:none;justify-content:center;align-items:center;position:fixed;top:0;left:0;right:0;bottom:0;z-index:999;} #hld__setting_panel {position:relative;background:#fff8e7;width:526px;padding:15px 20px;border-radius:10px;box-shadow:0 0 10px #666;border:1px solid #591804;} #hld__setting_panel > div.hld__field {float:left;width:50%;} #hld__setting_panel p {margin-bottom:10px;} #hld__setting_panel .hld__sp-title {font-size:15px;font-weight:bold;text-align:center;} #hld__setting_panel .hld__sp-section {font-weight:bold;margin-top:20px;} .hld__setting-close {position:absolute;top:5px;right:5px;padding:3px 6px;background:#fff0cd;color:#591804;transition:all .2s ease;cursor:pointer;border-radius:4px;text-decoration:none;} .hld__setting-close:hover {background:#591804;color:#fff0cd;text-decoration:none;} #hld__setting_panel button {transition:all .2s ease;cursor:pointer;} .hld__advanced-setting {border-top: 1px solid #e0c19e;border-bottom: 1px solid #e0c19e;padding: 3px 0;margin-top:25px;} .hld__advanced-setting >span {font-weight:bold} .hld__advanced-setting >button {padding: 0px;margin-right:5px;width: 18px;text-align: center;} .hld__advanced-setting-panel {display:none;padding:5px 0;flex-wrap: wrap;} .hld__advanced-setting-panel>p {width:100%;} .hld__advanced-setting-panel>table {width:50%;} .hld__advanced-setting-panel>p {margin: 7px 0 !important;font-weight:bold;} .hld__advanced-setting-panel>p svg {height:16px;width:16px;vertical-align: top;margin-right:3px;} .hld__advanced-setting-panel>table td {padding-right:10px} .hld__advanced-setting-panel input[type=text],.hld__advanced-setting-panel input[type=number] {width:80px} .hld__adv-help {cursor:help;text-decoration: underline;} .hld__buttons {clear:both;display:flex;justify-content:space-between;padding-top:15px;} button.hld__btn {padding:3px 8px;border:1px solid #591804;background:#fff8e7;color:#591804;} button.hld__btn:hover {background:#591804;color:#fff0cd;} .hld__sp-fold {padding-left:23px;} .hld__sp-fold .hld__f-title {font-weight:bold;} .hld__help-tips {position: absolute;padding: 5px 10px;background: rgba(0,0,0,.6);color: #FFF;border-radius: 5px;z-index: 9999;} ` } /** * 快捷键模块 * @name shortCutKeys * @description 为模块提供快捷键切换的能力,提供修改,保存快捷键等 */ const shortCutKeys = { name: 'shortCutKeys', beforeFunc: function () { script.setting.normal.shortcutKeys = [] }, initFunc: function () { const _this = this // 添加到配置面板的设置入口 script.getModule('settingPanel').addButton({ id: 'hld__shortcut_manage', title: '编辑快捷键', desc: '编辑快捷键' }) /** * Bind:keyup * 注册监听按键 */ $('body').keyup(event => { if (/textarea|select|input/i.test(event.target.nodeName) || /text|password|number|email|url|range|date|month/i.test(event.target.type)) { return } if (event.ctrlKey || event.altKey || event.shiftKey) return for (const keyCode of script.setting.normal.shortcutKeys) { if (event.keyCode === keyCode) { for (const module of script.modules) { if (module.setting && module.shortcutFunc) { if (module.setting.rewriteShortCutCode) { if (module.setting.rewriteShortCutCode === event.keyCode) { module.shortcutFunc[module.setting.key].call(module) } } else if (module.setting.shortCutCode === event.keyCode) { module.shortcutFunc[module.setting.key].call(module) } } if (module.settings) { for (const setting of module.settings) { if (module.shortcutFunc) { if (setting.rewriteShortCutCode) { if (setting.rewriteShortCutCode === event.keyCode) { module.shortcutFunc[setting.key].call(module) } } else if (setting.shortCutCode === event.keyCode) { module.shortcutFunc[setting.key].call(module) } } } } } } } }) /** * Bind:Click * 快捷键编辑面板 */ $('body').on('click', '#hld__shortcut_manage', () => { if($('#hld__shortcut_panel').length > 0) return let $shortcutPanel = $(`
×

编辑快捷键

功能快捷键

支持的快捷键范围

键盘 A~Z

左箭头 LEFT

右箭头 RIGHT

上箭头 UP

下箭头 DOWN

* 留空则取消快捷键


如按键异常请尝试重置按键

`) const insertDom = setting => $shortcutPanel.find('.hld__table tbody').append(`${setting.title || setting.key}`) for (const module of script.modules) { if (module.setting && module.setting.shortCutCode) { insertDom(module.setting) } if (module.settings) { for (const setting of module.settings) { if (setting.shortCutCode) { insertDom(setting) } } } } $('#hld__setting_cover').append($shortcutPanel) }) /** * Bind:Click * 重置快捷键 */ $('body').on('click', '#hld__reset_shortcut', () => { const defaultShortcut = [] for (const module of script.modules) { if (module.setting && module.setting.shortCutCode) { defaultShortcut.push(module.setting.shortCutCode) } if (module.settings) { for (const setting of module.settings) { setting.shortCutCode && defaultShortcut.push(setting.shortCutCode) } } } script.setting.normal.shortcutKeys = defaultShortcut script.saveSetting('重置按键成功,刷新页面生效') $('#hld__shortcut_panel').remove() }) /** * Bind:Click * 保存快捷键 */ $('body').on('click', '#hld__save_shortcut', () => { const _this = this let shortcutKeys = [] $('.hld__table tbody>tr').each(function () { const v = $(this).find('input').val().trim().toUpperCase() if (v == '') { shortcutKeys.push(-1) } else { const code = _this.getCodeName(v, 'name') if (code > 0) shortcutKeys.push(code) else script.popMsg(`${v}是个无效的快捷键`, 'err') } }) if (shortcutKeys.length != script.setting.normal.shortcutKeys.length) return script.setting.normal.shortcutKeys = shortcutKeys script.saveSetting('保存按键成功,刷新页面生效') $('#hld__shortcut_panel').remove() }) }, getCodeName (val, valType='code') { const shortcutCode = { 'A': 65, 'B': 66, 'C': 67, 'D': 68, 'E': 69, 'F': 70, 'G': 71, 'H': 72, 'I': 73, 'J': 74, 'K': 75, 'L': 76, 'M': 77, 'N': 78, 'O': 79, 'P': 80, 'Q': 81, 'R': 82, 'S': 83, 'T': 84, 'U': 85, 'V': 86, 'W': 87, 'X': 88, 'Y': 89, 'Z': 90, '0': 48, '1': 49, '2': 50, '3': 51, '4': 52, '5': 53, '6': 54, '7': 55, '8': 56, '9': 57, 'LEFT': 37, 'RIGHT': 39, 'UP': 38, 'DOWN': 40, '': 0, '': -1 } if (valType == 'code') { let keyname = '' for (let [n, c] of Object.entries(shortcutCode)) { c == val && (keyname = n) } return keyname } else { let code = -1 for (let [n, c] of Object.entries(shortcutCode)) { n == val && (code = c) } return code } }, style: ` code {padding:2px 4px;font-size:90%;font-weight:bold;color:#c7254e;background-color:#f9f2f4;border-radius:4px;} .hld__list-panel {position:fixed;background:#fff8e7;padding:15px 20px;border-radius:10px;box-shadow:0 0 10px #666;border:1px solid #591804;z-index:9999;} .hld__list-panel .hld__list-c {width:45%;} .hld__list-panel .hld__list-c textarea {box-sizing:border-box;padding:0;margin:0;height:200px;width:100%;resize:none;} .hld__list-panel .hld__list-desc {margin-top:5px;font-size:9px;color:#666;cursor:help;text-decoration: underline;} .hld__list-panel .hld__list-c > p:first-child {font-weight:bold;font-size:14px;margin-bottom:10px;} .hld__table-keyword {margin-top:10px;width:200px;} .hld__table-keyword tr td:last-child {text-align:center;} .hld__table-keyword input[type=text] {width:48px;text-transform:uppercase;text-align:center;} .hld__table{table-layout:fixed;border-top:1px solid #ead5bc;border-left:1px solid #ead5bc} .hld__table-banlist-buttons{margin-top:10px} .hld__table thead{background:#591804;border:1px solid #591804;color:#fff} .hld__table td,.hld__table th{padding:3px 5px;border-bottom:1px solid #ead5bc;border-right:1px solid #ead5bc;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .hld__shortcut-desc {width:120px;margin-left:20px;padding-top:6px} .hld__shortcut-desc p {margin-bottom:5px;} ` } /** * 配置备份模块 * @name backupModule * @description 提供配置的导入,导出功能 */ const backupModule = { name: 'backupModule', backupItems: [], initFunc: function () { /** * 导入导出设置面板 */ const _this = this // 在设置面板上添加按钮 script.getModule('settingPanel').addButton({ id: 'hld__backup_panel', title: '导入/导出', desc: '导入/导出配置字符串,包含设置,黑名单,标记名单等等' }) /** * Bind:Click * 导入导出面板 */ $('body').on('click', '#hld__backup_panel', function () { const unsupported = '3.3.0' const currentVer = script.getInfo().version if($('#hld__export_panel').length > 0) return $('#hld__setting_cover').append(`
×

选择导出的设置


字符串

`) // 加载其他模组备份项 for (const item of _this.backupItems) { $('#hld__export_panel_cb').append(`

`) } /** * Bind:Click * 导出配置 */ $('#hld__export__data').click(function(){ let obj = {} // 基础配置 if ($('#hld__cb_export_setting').prop('checked')) { obj['setting'] = script.setting.normal obj['advanced_setting'] = script.setting.advanced } // 其他模组备份项 for (const item of _this.backupItems) { const $c = $(`#hld__cb_export_${item.writeKey}`) if ($c.length > 0 && $c.prop('checked')) { obj[item.writeKey] = item.module[item.valueKey] } } if (Object.keys(obj).length == 0) { $('#hld__export_msg').html('没有选择任何项目可供导出!') return } obj['name'] = 'HLD-NGA-SCRIPT' obj['ver'] = script.getInfo().version const backupB64 = _this.Base64.encode(JSON.stringify(obj)) $('#hld__export_str').val(backupB64) $('#hld__export_msg').html(`导出成功(${_this.calculateSize(backupB64.length)}),请复制右侧字符串以备份`) }) /** * Bind:Click * 导入配置 */ $('#hld__import__data').click(function(){ if ($('#hld__export_str').val()) { try { let obj = JSON.parse(_this.Base64.decode($('#hld__export_str').val())) const objVer = _this.vstr2num(obj.ver) if (objVer != 0 && objVer > _this.vstr2num(currentVer)) { script.popMsg(`此配置是由更高版本(v${obj.ver})的脚本导出,请升级您的脚本 [脚本地址]`, 'warn') return } if (objVer != 0 && objVer < _this.vstr2num(unsupported)) { script.popMsg(`此配置是由低版本(v${obj.ver})的脚本导出,当前版本(v${currentVer})已不支持!`, 'err') return } let confirm = window.confirm('此操作会覆盖你的配置,确认吗?') if (!confirm) return if (Object.keys(obj).includes('setting')) { obj.setting && (script.setting.normal = obj.setting) obj.advanced_setting && (script.setting.advanced = obj.advanced_setting) window.localStorage.setItem('hld__NGA_setting', JSON.stringify(script.setting.normal)) window.localStorage.setItem('hld__NGA_advanced_setting', JSON.stringify(script.setting.advanced)) } // 其他模组备份项 for (const item of _this.backupItems) { if (Object.keys(obj).includes(item.writeKey)) { item.module[item.valueKey] = obj[item.writeKey] window.localStorage.setItem(`hld__NGA_${item.writeKey}`, JSON.stringify(obj[item.writeKey])) } } $('#hld__export_msg').html('导入成功,刷新浏览器以生效') } catch (err){ script.printLog(`JSON解析失败:${err}`) $('#hld__export_msg').html('字符串有误,解析失败!') } } }) }) }, addItem: function(item) { this.backupItems.push(item) }, // 字符串版本转数字 vstr2num: function(str) { let num = 0 str.split('.').forEach((n, i) => num += i < 2 ? +n * 1000 / Math.pow(10, i) : +n) return num }, calculateSize: function (num) { if (num == 0) return '0 B' let k = 1024 let sizeStr = ['B','KB','MB','GB'] let i = 0 for(let l=0;l<8;l++){   if(num / Math.pow(k, l) < 1) break   i = l }   return (num / Math.pow(k, i)).toFixed(2) + ' ' + sizeStr[i] }, /** * Base64互转 */ Base64: { encode: (str) => { return window.btoa(unescape(encodeURIComponent(str))) }, decode: (str) => { return decodeURIComponent(escape(window.atob(str))) } }, style: ` .hld__ep-container{display:flex;width:300px;margin-bottom: 7px;} .hld__ep-container p {margin-bottom:10px;} .hld__ep-container >div{width:50%;} .hld__ep-container textarea {width: 100%;padding:0;margin:0;resize:none;} ` } /** * 赏面板 * @name rewardPanel * @description 别问,好活当赏 */ const rewardPanel = { name: 'rewardPanel', initFunc: function () { /** * 打赏 */ script.getModule('settingPanel').addButton({ id: 'hld__reward', title: '¥赏', desc: '好活当赏' }) /** * Bind:Click * 打赏面板 */ $('body').on('click', '#hld__reward', function () { $('#hld__setting_cover').append(`
×

本脚本完全开源,并且长期维护,您喜欢请可以去Github点个Star!

您若有好的功能需求或者建议,欢迎反馈

如果您觉得脚本好用帮助到更好的摸鱼,也可以请作者喝杯咖啡~

Mozilla Add-on Mozilla Add-on
`) }) }, style: ` .hld__reward-panel {width:500px;} .hld__reward-panel .hld__reward-info {display:block;font-size:15px;margin-bottom:20px;line-height:20px;} .hld__reward-panel .hld__reward-info p {margin-bottom:5px;} .hld__delete-line {text-decoration:line-through;color:#666;} .hld__reward-panel .hld__list-c {width:50%;} .hld__reward-panel .hld__list-c:first-child {margin-right:15px;} .hld__reward-panel .hld__list-c>img {width:100%;height:auto;} .hld__reward-panel .hld__source {margin-top:15px;} .hld__reward-panel .hld__source > a {margin-right:10px;} ` } /** * 动态启用配置模块 * @name dynamicEnable * @description 此模块提供了快捷键动态启用的功能 */ const dynamicEnable = { name: 'dynamicEnable', setting: { type: 'advanced', key: 'dynamicEnable', default: true, title: '动态功能启用', desc: '此配置表示部分可以快捷键切换的功能默认行为策略\n选中时:关闭功能(如隐藏头像)也可以通过快捷键切换显示/隐藏\n取消时:关闭功能(如隐藏头像)将彻底关闭功能,快捷键会失效', menu: 'left' } } /** * 隐藏头像模块 * @name hideAvatar * @description 此模块提供了可以快捷键切换显示隐藏头像 */ const hideAvatar = { name: 'hideAvatar', setting: { shortCutCode: 81, // Q type: 'normal', key: 'hideAvatar', default: true, title: '隐藏头像', menu: 'left' }, renderFormsFunc: function ($el) { script.setting.normal.hideAvatar && $el.find('.avatar, .avatar+img').css('display', 'none') }, shortcutFunc: { hideAvatar: function () { if (script.setting.normal.hideAvatar || script.setting.advanced.dynamicEnable) { $('.avatar, .avatar+img').toggle() script.popNotification(`${$('.avatar:hidden').length == 0 ? '显示' : '隐藏'}头像`) } } }, asyncStyle: function () { return ` .posterinfo .avatar+img {display:${script.setting.normal.hideAvatar ? 'none' : 'inline'};} ` } } /** * 隐藏头像模块 * @name hideSmile * @description 此模块提供了可以快捷键切换显示隐藏表情 * 其中隐藏的表情会用文字来替代 */ const hideSmile = { name: 'hideSmile', setting: { shortCutCode: 87, // W type: 'normal', key: 'hideSmile', default: true, title: '隐藏表情', menu: 'left' }, renderFormsFunc: function ($el) { $el.find('.c2 img').each(function () { const classs = $(this).attr('class') if (classs && classs.includes('smile') && !$(this).is(':hidden')) { const alt = $(this).attr('alt') const $alt = $('[' + alt + ']') script.setting.normal.hideSmile ? $(this).hide() : $alt.hide() $(this).after($alt) } }) }, shortcutFunc: { hideSmile: function () { if (script.setting.normal.hideSmile || script.setting.advanced.dynamicEnable) { $('.c2 img').each(function () { const classs = $(this).attr('class'); if (classs && classs.includes('smile')) $(this).toggle() }) $('.smile_alt_text').toggle() script.popNotification(`${$('.smile_alt_text:hidden').length > 0 ? '显示' : '隐藏'}表情`) } } } } /** * 贴内图片缩放模块 * @name imgResize * @description 此模块提供了可以调整贴内图片的尺寸 */ const imgResize = { name: 'imgResize', settings: [{ type: 'normal', key: 'imgResize', title: '贴内图片缩放', default: true, menu: 'left' }, { type: 'advanced', key: 'imgResizeWidth', default: 200, title: '图片缩放宽度', desc: '贴内图片缩放的宽度,高度自适应,单位px', menu: 'left' }], renderFormsFunc: function ($el) { $el.find('.c2 img').each(function () { const classs = $(this).attr('class') if ((!classs || !classs.includes('smile')) && script.setting.normal.imgResize) { $(this).addClass('hld__img-resize').attr('hld-img-resize', 'ok').attr('title', '点击大图显示') } }) }, asyncStyle: () => { return ` .hld__img-resize {outline:none !important;outline-offset:'';cursor:alias;min-width:auto !important;min-height:auto !important;max-width:${script.setting.advanced.imgResizeWidth || 200}px !important;margin:5px;} ` } } /** * 隐藏图片模块 * @name hideImage * @description 此模块提供了可以快捷键切换显示隐藏图片 * 其中隐藏的图片会用一个按钮来替代 */ const hideImage = { name: 'hideImage', setting: { shortCutCode: 69, // E type: 'normal', key: 'hideImage', default: false, title: '隐藏贴内图片', menu: 'left' }, renderFormsFunc: function ($el) { $el.find('.c2 img').each(function () { const classs = $(this).attr('class') if ((!classs || !classs.includes('smile')) && !$(this).is(':hidden')) { $(this).addClass('hld__img-postimg') // 显示原图 $(this).attr('src', $(this).attr('src').replace('.medium.jpg', '')).attr('hld-hideimg', 'ok') let $imgB = $('') $imgB.on('click', function () { $(this).prev('img').toggle() $(this).text($(this).prev('img').is(':hidden') ? '图' : '隐藏') }) if (script.setting.normal.hideImage) { $(this).hide(); $imgB.show() } $(this).after($imgB) } }) }, shortcutFunc: { hideImage: function () { if (!script.setting.advanced.dynamicEnable) return if ($('.hld__img-postimg:hidden').length < $('.switch-img').length) { $('.hld__img-postimg').hide() $('.switch-img').text('图').show() script.popNotification(`隐藏图片`) return } $('.hld__img-postimg').each(function () { $(this).toggle() $(this).is(':hidden') ? $(this).next('button.switch-img').show() : $(this).next('button.switch-img').hide() }) script.popNotification(`${$('.switch-img:hidden').length > 0 ? '显示' : '隐藏'}图片`) } } } /** * 隐藏签名模块 * @name hideSign * @description 此模块提供了可以配置默认隐藏签名 */ const hideSign = { name: 'hideSign', setting: { type: 'normal', key: 'hideSign', default: true, title: '隐藏签名', menu: 'left' }, renderFormsFunc: function ($el) { script.setting.normal.hideSign && $el.find('.sign, .sigline').css('display', 'none') } } /** * 隐藏图片模块 * @name hideHeader * @description 此模块提供了可以配置默认隐藏版头 * 以及一个高级配置可选一起隐藏顶部背景 */ const hideHeader = { name: 'hideHeader', settings: [{ type: 'normal', key: 'hideHeader', default: true, title: '隐藏版头/版规/子版入口', menu: 'left' }, { type: 'advanced', key: 'hideCustomBg', default: true, title: '隐藏版头同时隐藏背景图片', desc: '选中时:隐藏版头顶部背景图片\n取消时:无操作', menu: 'right' }], renderAlwaysFunc: function ($el) { //隐藏版头 if (script.setting.normal.hideHeader && $('#hld__switch_header').length == 0) { $('#toppedtopic, #sub_forums').hide() let $toggleHeaderBtn = $('') $toggleHeaderBtn.click(() => $('#toppedtopic, #sub_forums').toggle()) $('#toptopics > div > h3').append($toggleHeaderBtn) } if(script.setting.normal.hideHeader && script.setting.advanced.hideCustomBg) { $('#custombg').hide() $('#mainmenu').css('margin', '0px') } }, style: ` #m_threads .toptopicsRight {float:none;width:auto;} .topicrowsLeftC {margin-right:0;} ` } /** * Excel模块 * @name excelMode * @description 此模块提供了可以快捷键切换Excel模式 * 以及一个高级配置可选更改Excel左侧序号的类型 */ const excelMode = { name: 'excelMode', settings: [{ shortCutCode: 82, // R type: 'normal', key: 'excelMode', default: false, title: 'Excel模式', menu: 'left' }, { type: 'advanced', key: 'excelTheme', default: 'wps', options: [{ label: 'WPS', value: 'wps' }, { label: 'Office', value: 'office' }], title: 'Excel皮肤', desc: 'Excel的皮肤', menu: 'left' }, { type: 'advanced', key: 'excelNoMode', default: false, title: 'Excel左列序号', desc: 'Excel最左列的显示序号,此策略为尽可能的更像Excel\n选中时:Excel最左栏为从1开始往下,逐行+1\n取消时:Excel最左栏为原始的回帖数\n*此功能仅在贴列表有效', menu: 'left' }], beforeUrl: window.location.href, initFunc: function() { // 生成列标题字母列表 const columnLetters = () => { let capital = [] let columnLetters = [] for (let i=65;i<91;i++) capital.push(String.fromCharCode(i)) Array('', 'A', 'B', 'C').forEach(n => capital.forEach(c => columnLetters.push(`${n}${c}`))) return columnLetters } // 插入Excel头部 $('body').append(`
${script.setting.advanced.excelTitle || document.title} - Excel
${(columnLetters().map(c => '
'+c+'
')).join('')}
`) // 插入Excel尾部 $('body').append(` `) $('#hld__excel_setting').click(()=>$('#hld__setting_cover').css('display', 'flex')) $('#mainmenu .half').parent().append($('#mainmenu .half').clone(true).addClass('hld__half-clone').text($('#mainmenu .half').text().replace('你好', ''))) if(script.setting.normal.excelMode) { if(this.beforeUrl.includes('thread.php') || this.beforeUrl.includes('read.php')) { this.switchExcelMode() } } }, renderAlwaysFunc: function ($el) { $('.hld__excel-theme-' + script.setting.advanced.excelTheme).length == 0 && $('body').addClass('hld__excel-theme-' + script.setting.advanced.excelTheme) if(script.setting.normal.excelMode && window.location.href != this.beforeUrl) { this.beforeUrl = window.location.href if(this.beforeUrl.includes('thread.php') || this.beforeUrl.includes('read.php')) { $('.hld__excel-body').length == 0 && $('body').addClass('hld__excel-body') }else { $('.hld__excel-body').length > 0 && $('body').removeClass('hld__excel-body') } } if(script.setting.normal.excelMode && $('.hld__excel-body').length > 0 && $('#mmc').length == 0) { $('body').addClass('hld__excel-body-err') }else { $('body').removeClass('hld__excel-body-err') } }, renderFormsFunc: function ($el) { $el.find('.postrow>td:first-child').before('') }, shortcutFunc: { excelMode: function () { if (script.setting.normal.excelMode || script.setting.advanced.dynamicEnable) { this.switchExcelMode() script.popNotification($('.hld__excel-body').length > 0 ? 'Excel模式' : '普通模式') } } }, /** * 切换Excel模式 * @method switchExcelMode */ switchExcelMode: () => { $('body').toggleClass('hld__excel-body') !script.setting.advanced.excelNoMode && $('body').addClass('hld__excel-original-no') }, style: ` /* 默认风格(WPS) */ .hld__excel-body-err {padding-top: 200px} .hld__excel-header, .hld__excel-footer, .hld__excel-setting, .hld__half-clone {display: none;} .hld__excel-header>div, .hld__excel-footer>div {position: relative;box-sizing: border-box;} .hld__excel-header img, .hld__excel-footer img {position: absolute;} .hld__excel-header {border-bottom:1px solid #bbbbbb;} .hld__excel-title {display:none;} .hld__excel-h1 {height:30px;background:#f3f5f8;border-bottom:1px solid #c5cbd6;} .hld__excel-h2 {height:102px;background:#f4f4f4;} .hld__excel-img-h1-l1, .hld__excel-img-h2-l1, .hld__excel-img-f1-l1, .hld__excel-img-fl2 {top:0;left:0;} .hld__excel-img-h1-r1, .hld__excel-img-h2-r1, .hld__excel-img-f1-r1, .hld__excel-img-fr2 {top:0;right:0;} .hld__excel-h3 {height:44px;background:#e8e8e8;box-shadow: inset 0 3px 5px #d9d9d9;} .hld__excel-img-h3-l1 {top:12px;left:0;} .hld__excel-img-h3-r1 {toP:8px;right:0;} .hld__excel-fx {position: absolute;top:12px;left:253px;right:45px;height:24px;box-sizing: border-box;border:1px solid #cccccc;border-radius:4px;background:#ffffff;} .hld__excel-h4 {height:21px;display:flex;flex-wrap: wrap;overflow: hidden;} .hld__excel-h4 > div {height:21px;border-right:1px solid #c8c8c8;box-sizing:border-box;} .hld__excel-sub {width:34px;position: relative;} .hld__excel-sub > div {position: absolute;right:4px;bottom:4px;width: 0px;height: 0px;border-top: 6px solid transparent;border-left: 6px solid transparent;border-right: 6px solid #b8b8b8;border-bottom: 6px solid #b8b8b8;} .hld__excel-column {width: 72px;line-height:21px;text-align:center;color:#444444;font-family: sans-serif;font-weight:100;font-size:14px;} .hld__excel-f1 {height:22px;background:#e8e8e8;} .hld__excel-f2 {height:28px;background:#f4f4f4;} .hld__excel-body {background:#fff !important;} .hld__excel-body #mainmenu {position: fixed;top: 5px;right: 75px;width: 425px;z-index: 98;} .hld__excel-body #mainmenu .right {float:none;} .hld__excel-body #mainmenu .stdbtn {background:none;box-shadow:none;} .hld__excel-body #mainmenu .half {display:none;} .hld__excel-body #mainmenu .hld__half-clone {display:block;width: 150px;text-align: right;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;} .hld__excel-body #mainmenu .half {color:#f4f4f4 !important;} .hld__excel-body #mainmenu .stdbtn a:hover {background:none;text-decoration:underline;color:#2c5787 !important;} .hld__excel-body #mainmenu .mmdefault.cell input {padding:0;margin:0;background:#ededed;border:1px solid #c9d0dc;border-radius:10px;box-shadow:none;font-size:13px !important;} .hld__excel-body #mainmenu, .hld__excel-body #mainmenu .half, .hld__excel-body #mainmenu td a, .hld__excel-body #mainmenu .stdbtn .innerbg, .hld__excel-body #mainmenu, .hld__excel-body #mainmenu .stdbtn a, .hld__excel-body #mainmenu .stdbtn .td {height: 20px !important;line-height: 20px !important;padding: 0 5px !important;background:none;color:#424242 !important;} .hld__excel-body .single_ttip2 {position: fixed !important;z-index:999 !important;top:30px !important;border-color:#888;} .hld__excel-body .hld__excel-body #mainmenu, .hld__excel-body .catenew,.hld__excel-body #toptopics,.hld__excel-body #m_pbtntop,.hld__excel-body #m_fopts,.hld__excel-body #b_nav,.hld__excel-body #fast_post_c,.hld__excel-body #custombg,.hld__excel-body #m_threads th,.hld__excel-body #m_posts th,.hld__excel-body .r_container,.hld__excel-body #footer,.hld__excel-body .clickextend {display:none !important;} .hld__excel-body #mmc {margin-top:195px;margin-bottom:35px;} .hld__excel-body .postBtnPos > div, .hld__excel-body .postBtnPos .stdbtn a {background:#fff !important;border-color:#bbb;} .hld__excel-body .hld__excel-div,.hld__excel-body .hld__excel-setting {display:block;} .hld__excel-body .hld__excel-setting {position:fixed;width:60px;height:20px;top:5px;right:95px;background:#f2f4f7;z-index:999;} .hld__excel-body .hld__excel-setting img {width:20px;height:auto;vertical-align:middle;} .hld__excel-body .hld__excel-setting a {margin-left:5px;vertical-align:middle;} .hld__excel-body .hld__excel-header {position:fixed;top:0;left:0;height:196px;} .hld__excel-body .hld__excel-footer {position:fixed;bottom:0;left:0;height:50px;} .hld__excel-body .hld__excel-header, .hld__excel-body .hld__excel-footer {width: 100%;text-align: center;font-size: 16px;font-weight: bold;background:#e8e8e8;color:#337ab7;line-height: 45px;} .hld__excel-body .hld__excel-header>img, .hld__excel-body .hld__excel-footer>img{position:absolute;top:0;left:0} .hld__excel-body #m_nav {position:fixed;top:136px;left:261px;margin:0;padding:0;z-index:99;width: 9999px;} .hld__excel-body #m_nav .nav_spr {display:block;border:0;border-radius:0;padding:0;box-shadow:none;background:none;} .hld__excel-body #m_nav .nav_spr span {color:#000;font-size:16px;vertical-align:unset;font-weight:normal;} .hld__excel-body #m_nav .nav_root,.hld__excel-body #m_nav .nav_link {background:none;border:none;box-shadow:none;padding:0;color:#000;border-radius:0;font-weight:normal;} .hld__excel-body .nav {font-size:14px !important;} .hld__excel-body #mainmenu .stdbtn a {font-size:13px !important;} .hld__excel-body #m_threads {margin:0;} .hld__excel-body #topicrows {border:none;box-shadow:none;border-radius:0;margin:0;background-color:#fff;counter-reset:num;border-spacing:0;} .hld__excel-body #topicrows tbody {border-spacing:0;} .hld__excel-body .topicrow {border-spacing:0;} .hld__excel-body #topicrows td {background:#fff;padding:5px 0;margin:0;border:none;border-right:1px solid #bbbbbb;border-bottom:1px solid #bbbbbb;margin-right:-1px;} .hld__excel-body .topicrow .c1 {width:33px;background:#e8e8e8 !important;} .hld__excel-body .topicrow .c1 a {display:none;color: #777777 !important;font-size: 16px !important;font-family: auto;width: 30px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;} .hld__excel-body.hld__excel-original-no .topicrow .c1:before {display:none;} .hld__excel-body.hld__excel-original-no .topicrow .c1 a {display:inline-block;} .hld__excel-body.hld__excel-original-no .topicrow .c1 img {width:20px;} .hld__excel-body .topicrow .c1:before {content:counter(num);counter-increment:num;color:#777777;font-size:16px;} .hld__excel-body .topicrow .c2 {padding-left:5px !important;} .hld__excel-body .topicrow .c3 {color:#1a3959 !important;} .hld__excel-body .topicrow .c3 > div, .hld__excel-body .topicrow .c4 > div {background:#FFF !important;} .hld__excel-body .topicrow .c3 > div a, .hld__excel-body .topicrow .c4 > div a {color:#888 !important;} .hld__excel-body .block_txt {background:#fff !important;color:#1a3959 !important;border-radius:0;padding:0 !important;min-width:0 !important;font-weight:normal;} .hld__excel-body .quote {background:#fff !important;} .hld__excel-body #m_posts .block_txt {font-weight:bold;} .hld__excel-body .topicrow .postdate,.hld__excel-body .topicrow .replydate {display:inline;margin:10px;} .hld__excel-body #m_pbtnbtm {margin:0;border-bottom:1px solid #bbbbbb;} .hld__excel-body #pagebbtm,.hld__excel-body #m_pbtnbtm .right_ {margin:0;} .hld__excel-body #pagebbtm:before {display:block;line-height:35px;width:33px;float:left;content:"#";border-right:1px solid #bbbbbb;color:#777;font-size:16px;background:#e8e8e8;} .hld__excel-body #m_pbtnbtm td {line-height:35px;padding:0 5px;} .hld__excel-body #m_pbtnbtm .stdbtn {box-shadow:none;border:none !important;padding:0;padding-left:5px;background:#fff;border-radius:0;font-size:13px !important;} .hld__excel-body #m_pbtnbtm .stdbtn .invert {color:#591804;} .hld__excel-body #m_pbtnbtm td a {background:#fff;padding:0;border:0;} .hld__excel-body #m_posts .comment_c .comment_c_1 {border-top-color:#bbbbbb;} .hld__excel-body #m_posts .comment_c .comment_c_2 {border-color:#bbbbbb;} .hld__excel-body #m_posts {border:0;box-shadow:none;padding-bottom:0;margin:0;counter-reset:num;} .hld__excel-body #m_posts td {background:#fff;border-right:1px solid #bbbbbb;border-bottom:1px solid #bbbbbb;} .hld__excel-body #m_posts .c0 {width:32px;color:#777;font-size:16px;background:#e8e8e8;text-align:center;} .hld__excel-body #m_posts .c0:before {content:counter(num);counter-increment:num;} .hld__excel-body #m_posts .vertmod {background:#fff !important;color:#ccc;} .hld__excel-body #m_posts a[name="uid"]:before {content:"UID:"} .hld__excel-body #m_posts .white,.hld__excel-body #m_posts .block_txt_c2,.hld__excel-body #m_posts .block_txt_c0 {background:#fff !important;color:#777777;} .hld__excel-body #m_posts .quote {background:#fff;border-color:#bbbbbb;} .hld__excel-body #m_posts button {background:#eee;} .hld__excel-body #m_posts .postbox {border:none !important;} .hld__excel-body .posterInfoLine {background: #FFF !important;border-bottom-color: #FFF !important;} .hld__excel-body.hld__reply-fixed #postbbtm {position:fixed;right:30px;top:75px;z-index:999;border-radius: 10px;overflow: hidden;} /* Office风格 */ .hld__excel-body.hld__excel-theme-office .hld__excel-header {height:221px;} .hld__excel-body.hld__excel-theme-office .hld__excel-h1 {height:59px;background:#227447;display:flex;justify-content: center;} .hld__excel-body.hld__excel-theme-office .hld__excel-title {display: block;color:#FFF;font-size: 12px;font-weight: 400;font-family: sans-serif;line-height:30px;} .hld__excel-body.hld__excel-theme-office .hld__excel-h2 {height:95px;background:#f1f1f1;border-bottom:1px solid #d5d5d5;} .hld__excel-body.hld__excel-theme-office .hld__excel-h3 {height:48px;background:#e6e6e6;box-shadow:none;} .hld__excel-body.hld__excel-theme-office .hld__excel-fx {left:250px;right: 5px;border-color:#c6c6c6;border-radius:0;height:28px;} .hld__excel-body.hld__excel-theme-office .hld__excel-h4 {height:20px;} .hld__excel-body.hld__excel-theme-office .hld__excel-f1 {height:29px;} .hld__excel-body.hld__excel-theme-office .hld__excel-f2 {height:21px;} .hld__excel-body.hld__excel-theme-office .hld__excel-f1 {border-top:1px solid #999999;border-bottom:1px solid #bfbfbf;} .hld__excel-body.hld__excel-theme-office .hld__excel-img-f1-l1, .hld__excel-body.hld__excel-theme-office .hld__excel-img-f1-r1 {top:-1px;} .hld__excel-body.hld__excel-theme-office #mmc {margin-top:221px;} .hld__excel-body.hld__excel-theme-office #m_nav {top:160px;} .hld__excel-body.hld__excel-theme-office #m_posts .c0, .hld__excel-body.hld__excel-theme-office .topicrow .c1 {width:32px;} .hld__excel-body.hld__excel-theme-office #pagebbtm:before, .hld__excel-body.hld__excel-theme-office .topicrow .c1 a {width:28px;} .hld__excel-body.hld__excel-theme-office .hld__excel-setting {top: 36px;background:none;text-align: center;} .hld__excel-body.hld__excel-theme-office .hld__excel-setting a {color:#FFFFFF;} .hld__excel-body.hld__excel-theme-office .hld__excel-setting img {display:none;} .hld__excel-body.hld__excel-theme-office.hld__reply-fixed #postbbtm {top: 162px;} .hld__excel-body.hld__excel-theme-office #m_pbtnbtm td a, .hld__excel-body.hld__excel-theme-office #m_pbtnbtm .stdbtn {background: none;} .hld__excel-body.hld__excel-theme-office #mainmenu {top:35px;right:45px;} .hld__excel-body.hld__excel-theme-office #mainmenu .mmdefault.cell input {border-radius:0;} .hld__excel-body.hld__excel-theme-office #mainmenu .stdbtn a, .hld__excel-body.hld__excel-theme-office #mainmenu .hld__half-clone {color:#FFF !important;} .hld__excel-body.hld__excel-theme-office .single_ttip2 {top:59px !important;} ` } /** * Excel标题栏标题模块 * @name excelTitle * @description 此模块提供了在Excel模式下可以更改标题的功能 * 提供一个高级配置输入自定义标题 */ const excelTitle = { name: 'excelTitle', setting: { type: 'advanced', key: 'excelTitle', default: '工作簿1', title: 'Excel覆盖标题', desc: 'Excel模式下标签栏的名称, 如留空, 则显示原始标题', menu: 'left' }, renderAlwaysFunc: function ($el) { if ($('.hld__excel-body').length > 0) { const excelTitle = script.setting.advanced.excelTitle if (excelTitle) { $(document).attr('title') != excelTitle && $(document).attr('title', excelTitle) } $('#hld__excel_icon').length == 0 && $('head').append(``) } } } /** * 折叠引用模块 * @name foldQuote * @description 此模块提供了可以选择配置自动折叠过长引用 * 提供一个高级配置可以设置折叠的阈值 */ const foldQuote = { name: 'foldQuote', settings: [{ type: 'normal', key: 'foldQuote', default: true, title: '折叠过长引用与附件', menu: 'left' },{ type: 'advanced', key: 'foldQuoteHeight', default: 300, title: '自动折叠引用高度', desc: '自动折叠引用的高度阈值,单位为像素(px)', menu: 'right' }], renderFormsFunc: function ($el) { if (script.setting.normal.foldQuote) { // 自动折叠过长引用 if ($el.find('.postcontent .quote').length > 0) { let $quote = $el.find('.postcontent .quote') if ($quote.height() > (script.setting.advanced.foldQuoteHeight || 300)) { const originalHeight = $quote.height() $quote.addClass('hld__quote-fold') const foldHeight = $quote.height() const $openBtn = $(`
`) $openBtn.on('click', 'button', function(){ $(this).parent().remove() $quote.removeClass('hld__quote-fold') }) $quote.append($openBtn) } } // 折叠附件 if ($el.find('h4.silver.subtitle').length > 0) { $el.find('h4.silver.subtitle').each(function (){ if ($(this).html() === '附件' && $(this).next().attr('id').includes('postattach')) { const $attach = $(this).next() $attach.hide() const $openBtn = $(``) $openBtn.on('click', function(){ $(this).remove() $attach.show() }) $(this).next().after($openBtn) } }) } } }, style: ` .hld__quote-fold{height:150px;overflow:hidden;position: relative;} .hld__quote-box{padding:10px;position: absolute;left:0;right:0;bottom:0;background:#f2eddf;} .hld__excel-body .hld__quote-box{background:#FFF;} ` } /** * 新页面打开模块 * @name linkTargetBlank * @description 此模块提供了可以选择配置在新页面打开链接 */ const linkTargetBlank = { name: 'linkTargetBlank', setting: { type: 'normal', key: 'linkTargetBlank', default: false, title: '论坛列表新窗口打开', menu: 'right' }, renderThreadsFunc: function ($el) { if (script.setting.normal.linkTargetBlank) { let $link = $el.find('.topic') $link.data('href', $link.attr('href')).attr('href', 'javascript:void(0)') $link.click(() => { window.open($link.data('href')) return false }) } } } /** * 链接直接跳转 * @name directLinkJump * @description 此模块提供了超链接等直接跳转无须弹窗确认 */ const directLinkJump = { name: 'directLinkJump', setting: { type: 'normal', key: 'directLinkJump', default: true, title: '链接直接跳转', menu: 'right' }, renderFormsFunc: function ($el) { if (script.setting.normal.directLinkJump) { $el.find('a[onclick]').each(function(){ if ($(this).attr('onclick').includes('showUrlAlert')) { $(this).removeAttr('onclick onmouseover onmouseout') } }) } } } /** * 图片增强模块 * @name imgEnhance * @description 此模块提供了图片增强功能,使用一个独立的图层打开图片 * 可以快速切换,缩放,旋转等 */ const imgEnhance = { name: 'imgEnhance', settings: [{ type: 'normal', key: 'imgEnhance', default: true, title: '贴内图片功能增强', menu: 'right' }, { shortCutCode: 37, // LEFT key: 'imgEnhancePrev', title: '楼内上一张图' }, { shortCutCode: 39, // RIGHT key: 'imgEnhanceNext', title: '楼内上一张图' }], renderFormsFunc: function ($el) { $el.find('img').each(function () { const classs = $(this).attr('class') if (!classs || (classs && !classs.includes('smile'))) { $(this).attr('hld__imglist', 'ready').removeAttr('onload') } }) //图片增强 if (script.setting.normal.imgEnhance) { const _this = this $('#mc').on('click', '.postcontent img[hld__imglist=ready]', function () { _this.resizeImg($(this)) return false }) } }, resizeImg: (el) => { if ($('#hld__img_full').length > 0) return let urlList = [] let currentIndex = el.parent().find('[hld__imglist=ready]').index(el) el.parent().find('[hld__imglist=ready]').each(function () { if ($(this).attr('src') != 'about:blank') { urlList.push($(this).data('srcorg') || $(this).data('srclazy') || $(this).attr('src')) } }) let $imgBox = $('
') let $imgContainer = $('
') let $img = $('') const renderImg = (index) => { let timer = null $('#loader').show() $imgContainer.css({ 'top': $(window).height() * 0.03 + 'px', 'left': (($(window).width() - ($(window).height()) * 0.85) / 2) + 'px', 'width': $(window).height() * 0.85 + 'px', 'height': $(window).height() * 0.85 + 'px' }) $img.css({ 'width': '', 'height': '' }).attr('src', urlList[index]).hide() timer = setInterval(() => { const w = $img.width() const h = $img.height() if (w > 0) { w > h ? $img.css({ 'width': '100%', 'height': 'auto' }) : $img.css({ 'height': '100%', 'width': 'auto' }) $img.show() $('#loader').hide() clearInterval(timer) } }, 1) } //当前图片 renderImg(currentIndex) $img.mousedown(function (e) { let endx = 0; let endy = 0; let left = parseInt($imgContainer.css("left")) let top = parseInt($imgContainer.css("top")) let downx = e.pageX let downy = e.pageY e.preventDefault() $(document).on("mousemove", function (es) { endx = es.pageX - downx + left endy = es.pageY - downy + top $imgContainer.css("left", endx + "px").css("top", endy + "px") return false }); }) $img.mouseup(function () { $(document).unbind("mousemove") }) $imgContainer.append($img) $imgBox.append($imgContainer) $imgBox.click(function (e) { !$(e.target).hasClass('hld__img') && $(this).remove() }) $imgBox.append(`
`) /** * Bind:Click * 切换图片 */ $imgBox.on('click', '.change', function () { if ($(this).hasClass('prev-img') && currentIndex - 1 >= 0) renderImg(--currentIndex) if ($(this).hasClass('next-img') && currentIndex + 1 < urlList.length) renderImg(++currentIndex) if ($(this).hasClass('rotate-right') || $(this).hasClass('rotate-left')) { let deg = ($img.data('rotate-deg') || 0) - ($(this).hasClass('rotate-right') ? 90 : -90) if (deg >= 360 || deg <= -360) deg = 0 $img.css('transform', `rotate(${deg}deg)`) $img.data('rotate-deg', deg) } else { $img.css('transform', '') $img.data('rotate-deg', 0) } window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty() return false; }) /** * Bind:MouseWheel * 大图鼠标滚动缩放 */ $imgBox.on("mousewheel DOMMouseScroll", function (e) { const delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); if ($imgContainer.width() > 50 || delta > 0) { const offsetY = $imgContainer.height() * 0.2 const offsetX = $imgContainer.width() * 0.2 let offsetTop = offsetY / 2 let offsetLeft = offsetX / 2 if ($(e.target).hasClass('hld__zoom-target')) { const targetOffsetX = Math.round(e.clientX - $imgContainer.position().left) const targetOffsetY = Math.round(e.clientY - $imgContainer.position().top) offsetLeft = (targetOffsetX / ($imgContainer.height() / 2)) * offsetLeft offsetTop = (targetOffsetY / ($imgContainer.height() / 2)) * offsetTop } if (delta > 0) { $imgContainer.css({ 'width': ($imgContainer.height() + offsetY) + 'px', 'height': ($imgContainer.height() + offsetY) + 'px', 'top': ($imgContainer.position().top - offsetTop) + 'px', 'left': ($imgContainer.position().left - offsetLeft) + 'px' }) } if (delta < 0) { $imgContainer.css({ 'width': ($imgContainer.height() - offsetY) + 'px', 'height': ($imgContainer.height() - offsetY) + 'px', 'top': ($imgContainer.position().top + offsetTop) + 'px', 'left': ($imgContainer.position().left + offsetLeft) + 'px' }) } } e.stopPropagation() return false }) /** * Bind:Keyup * Esc关闭大图 */ $('body').keyup(event => (event.keyCode == 27 && $('#hld__img_full').length > 0) && $('#hld__img_full').remove()) $('body').append($imgBox) }, shortcutFunc: { imgEnhancePrev: function () { if ($('#hld__img_full').length > 0) { $('#hld__img_full .prev-img').click() } }, imgEnhanceNext: function () { if ($('#hld__img_full').length > 0) { $('#hld__img_full .next-img').click() } } }, style: ` .hld__img_container {position:absolute;display:flex;justify-content:center;align-items:center;} .hld__if_control {position:absolute;display:flex;left:50%;bottom:15px;width:160px;margin-left:-80px;height:40px;background:rgba(0,0,0,0.6);z-index:9999999;} .postcontent img {margin:0 5px 5px 0 !important;box-shadow:none !important;outline:none !important;} #hld__img_full {position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.6);z-index:99999;} #hld__img_full img {cursor:move;transition:transform .2s ease;} #hld__img_full .hld__imgcenter {top:50%;left:50%;transform:translate(-50%,-50%);} #hld__img_full .change {width:40px;height:40px;cursor:pointer;} #hld__img_full .rotate-right,#hld__img_full .rotate-left {background:url(${IMG_ICON_REFRESH}) center no-repeat;background-size:25px;} #hld__img_full .rotate-right {transform:rotateY(180deg);} #hld__img_full .rotate-left:hover {transform:scale(1.2);} #hld__img_full .rotate-right:hover {transform:scale(1.2) rotateY(180deg);} #hld__img_full .next-img:hover {transform:scale(1.2) rotate(180deg);} #hld__img_full .prev-img,#hld__img_full .next-img {background:url(${IMG_ICON_LEFT}) center no-repeat;} #hld__img_full .next-img {transform:rotate(180deg);} #hld__img_full .prev-img:hover {transform:scale(1.2);} #hld__img_full .next-img:hover {transform:scale(1.2) rotate(180deg);} ` } /** * 标记楼主模块 * @name authorMark * @description 此模块提供了自动标记楼主,使其更醒目 */ const authorMark = { name: 'authorMark', setting: { type: 'normal', key: 'authorMark', default: true, title: '高亮楼主', menu: 'right' }, postAuthor: [], initFunc: function () { const localPostAuthor = window.localStorage.getItem('hld__NGA_post_author') localPostAuthor && (this.postAuthor = localPostAuthor.split(',')) }, renderFormsFunc: function ($el) { const _this = this if (script.setting.normal.authorMark) { const author = $('#postauthor0').text().replace('[楼主]', '') const tid = this.getQueryString('tid') const authorStr = `${tid}:${author}` if (author && !this.postAuthor.includes(authorStr)) { this.postAuthor.unshift(authorStr) > 10 && this.postAuthor.pop() window.localStorage.setItem('hld__NGA_post_author', this.postAuthor.join(',')) } $el.find('a.b').each(function () { const name = $(this).attr('hld-mark-before-name') || $(this).text().replace('[', '').replace(']', '') if (name && _this.postAuthor.includes(`${tid}:${name}`)) { $(this).append('') } }) } }, /** * 获取URL参数 * @method getQueryString * @param {String} name key * @return {String|null} value */ getQueryString: (name) => { let url = decodeURI(window.location.search.replace(/&/g, "&")) let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)") let r = url.substr(1).match(reg) if (r != null) return unescape(r[2]) return null }, asyncStyle: () => { return ` .hld__post-author {color:${script.setting.advanced.authorMarkColor || '#F00'};font-weight:bold;} ` } } /** * 标记楼主可选颜色模块 * @name authorMarkColor * @requires https://cdn.staticfile.org/spectrum/1.8.0/spectrum.js * @description 此模块提供了高级设置可选标记楼主的颜色 * 以及为其他模块提供一个spectrum的配置文件 */ const authorMarkColor = { name: 'authorMarkColor', setting: { type: 'advanced', key: 'authorMarkColor', default: '#F00', title: '标记楼主颜色', desc: '标记楼主中的[楼主]的颜色,单位为16进制颜色代码', menu: 'left' }, // spectrum配置对象 colorPickerConfig: { type: 'color', preferredFormat: 'hex', showPaletteOnly: 'true', togglePaletteOnly: 'true', hideAfterPaletteSelect: 'true', showAlpha: 'false', togglePaletteMoreText: '更多选项', togglePaletteLessText: '隐藏', palette: [ ['#000000','#444444','#5b5b5b','#999999','#bcbcbc','#eeeeee','#f3f6f4','#ffffff'], ['#f44336','#744700','#ce7e00','#8fce00','#2986cc','#16537e','#6a329f','#c90076'], ['#f4cccc','#fce5cd','#fff2cc','#d9ead3','#d0e0e3','#cfe2f3','#d9d2e9','#ead1dc'], ['#ea9999','#f9cb9c','#ffe599','#b6d7a8','#a2c4c9','#9fc5e8','#b4a7d6','#d5a6bd'], ['#e06666','#f6b26b','#ffd966','#93c47d','#76a5af','#6fa8dc','#8e7cc3','#c27ba0'], ['#cc0000','#e69138','#f1c232','#6aa84f','#45818e','#3d85c6','#674ea7','#a64d79'], ['#990000','#b45f06','#bf9000','#38761d','#134f5c','#0b5394','#351c75','#741b47'], ['#660000','#783f04','#7f6000','#274e13','#0c343d','#073763','#20124d','#4c1130'] ] }, initFunc: function() { $('#hld__setting_cover').find('#hld__adv_authorMarkColor').spectrum(this.colorPickerConfig) }, style: ` .cp-color-picker{z-index:99997} .sp-container{position:absolute;top:0;left:0;display:inline-block;z-index:9999994;overflow:hidden} .sp-original-input-container{position:relative;display:inline-flex} .sp-original-input-container input{margin:0!important} .sp-original-input-container .sp-add-on{width:40px;border-top-right-radius:0!important;border-bottom-right-radius:0!important} input.spectrum.with-add-on{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0} .sp-original-input-container .sp-add-on .sp-colorize{height:100%;width:100%;border-radius:inherit} .sp-colorize-container{background-image:url(${IMG_ICON_ALPHA})} .sp-container.sp-flat{position:relative} .sp-container,.sp-container *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box} .sp-top{position:relative;width:100%;display:inline-block} .sp-top-inner{position:absolute;top:0;left:0;bottom:0;right:0} .sp-color{position:absolute;top:0;left:0;bottom:0;right:20px!important} .sp-hue{position:absolute;top:0;right:0;bottom:0;width:12px;height:100%;left:initial!important} .sp-clear-enabled .sp-hue{top:15%;height:85%} .sp-fill{padding-top:80%} .sp-sat,.sp-val{position:absolute;top:0;left:0;right:0;bottom:0} .sp-alpha-enabled .sp-top{margin-bottom:28px!important} .sp-alpha-enabled .sp-alpha{display:block} .sp-alpha-handle{position:absolute;top:-3px;cursor:pointer;height:16px;border-radius:50%;width:16px;margin-right:5px;left:-2px;right:0;background:#f9f9f9;box-shadow:0 0 2px 0 #3a3a3a} .sp-alpha{display:none;position:absolute;bottom:-18px;right:0;left:0;height:10px} .sp-alpha-inner{border-radius:4px} .sp-clear{display:none} .sp-clear.sp-clear-display{background-position:center} .sp-clear-enabled .sp-clear{display:block;position:absolute;top:3px;right:0;bottom:0;cursor:pointer;left:initial;height:12px;width:12px} .sp-alpha,.sp-alpha-handle,.sp-clear,.sp-container,.sp-container button,.sp-container.sp-dragging .sp-input,.sp-dragger,.sp-preview,.sp-replacer,.sp-slider{-webkit-user-select:none;-moz-user-select:-moz-none;-o-user-select:none;user-select:none} .sp-container.sp-input-disabled .sp-input-container{display:none} .sp-container.sp-buttons-disabled .sp-button-container{display:none} .sp-container.sp-palette-buttons-disabled .sp-palette-button-container{display:none} .sp-palette-only .sp-picker-container{display:none} .sp-palette-disabled .sp-palette-container{display:none} .sp-initial-disabled .sp-initial{display:none} .sp-sat{background-image:-webkit-gradient(linear,0 0,100% 0,from(#fff),to(rgba(204,154,129,0)));background-image:-webkit-linear-gradient(left,#fff,rgba(204,154,129,0));background-image:-moz-linear-gradient(left,#fff,rgba(204,154,129,0));background-image:-o-linear-gradient(left,#fff,rgba(204,154,129,0));background-image:-ms-linear-gradient(left,#fff,rgba(204,154,129,0));background-image:linear-gradient(to right,#fff,rgba(204,154,129,0))} .sp-val{border-radius:4px;background-image:-webkit-gradient(linear,0 100%,0 0,from(#000),to(rgba(204,154,129,0)));background-image:-webkit-linear-gradient(bottom,#000,rgba(204,154,129,0));background-image:-moz-linear-gradient(bottom,#000,rgba(204,154,129,0));background-image:-o-linear-gradient(bottom,#000,rgba(204,154,129,0));background-image:-ms-linear-gradient(bottom,#000,rgba(204,154,129,0));background-image:linear-gradient(to top,#000,rgba(204,154,129,0))} .sp-hue{background:-moz-linear-gradient(top,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%);background:-ms-linear-gradient(top,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%);background:-o-linear-gradient(top,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%);background:-webkit-gradient(linear,left top,left bottom,from(red),color-stop(.17,#ff0),color-stop(.33,#0f0),color-stop(.5,#0ff),color-stop(.67,#00f),color-stop(.83,#f0f),to(red));background:-webkit-linear-gradient(top,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%);background:linear-gradient(to bottom,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)} .sp-1{height:17%} .sp-2{height:16%} .sp-3{height:17%} .sp-4{height:17%} .sp-5{height:16%} .sp-6{height:17%} .sp-hidden{display:none!important} .sp-cf:after,.sp-cf:before{content:"";display:table} .sp-cf:after{clear:both} @media (max-device-width:480px){.sp-color{right:40%} .sp-hue{left:63%} .sp-fill{padding-top:60%} } .sp-dragger{border-radius:5px;height:10px;width:10px;border:1px solid #fff;cursor:pointer;position:absolute;top:0;left:0;margin-left:3px;margin-top:3px;box-shadow:0 0 2px 1px rgba(0,0,0,.2)} .sp-slider{position:absolute;top:0;cursor:pointer;height:16px;border-radius:50%;width:16px;left:-2px;background:#f9f9f9;box-shadow:0 0 2px 0 #3a3a3a;margin-top:8px} .sp-container{display:inline-flex;border-radius:0;background-color:#fff;padding:0;border-radius:4px;color:#000;box-shadow:0 0 0 1px rgba(99,114,130,.16),0 8px 16px rgba(27,39,51,.08)} .sp-clear,.sp-color,.sp-container,.sp-container button,.sp-container input,.sp-hue{font-size:12px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box} .sp-top{margin-bottom:10px} .sp-clear,.sp-color,.sp-hue,.sp-sat,.sp-val{border-radius:3px} .sp-input-container{margin-top:-5px} .sp-button-container.sp-cf,.sp-initial.sp-thumb.sp-cf,.sp-input-container.sp-cf{height:25px} .sp-picker-container .sp-cf{margin-bottom:10px} .sp-palette-row-initial>span:first-child{cursor:pointer} .sp-initial-disabled .sp-input-container{width:100%} .sp-input{padding:0 5px!important;margin:0;width:100%;box-shadow:none!important;height:100%!important;background:0 0;color:#3a3a3a;border-radius:2px!important;border:1px solid #e0e0e0!important;text-align:center;font-family:monospace;font-size:inherit!important} .sp-input.sp-validation-error{border:1px solid red;background:#fdd} .sp-palette-container,.sp-picker-container{position:relative;padding:10px} .sp-picker-container{width:200px;padding-bottom:0} .sp-palette-container{border-right:solid 1px #ccc} .sp-palette-only .sp-palette-container{border:0} .sp-palette .sp-thumb-el{display:block;position:relative;float:left;width:24px;height:15px;margin:3px;cursor:pointer;border:solid 2px transparent} .sp-palette .sp-thumb-el.sp-thumb-active,.sp-palette .sp-thumb-el:hover{border-color:orange} .sp-thumb-el{position:relative} .sp-initial{float:left} .sp-initial span{width:30px;height:25px;border:none;display:block;float:left;margin:0} .sp-initial .spe-thumb-el.sp-thumb-active{border-radius:0 5px 5px 0} .sp-initial .spe-thumb-el{border-radius:5px 0 0 5px} .sp-initial .sp-clear-display{background-position:center} .sp-button-container{float:right;display:none;} .sp-palette-button-container{margin-top:10px} .sp-replacer{position:relative;overflow:hidden;cursor:pointer;display:inline-block;border-radius:3px;border:1px solid #aaa;color:#666;transition:border-color .3s;vertical-align:middle;width:40px;height:20px;margin: 1.5px 3px;} .sp-replacer.sp-active,.sp-replacer:hover{border:1px solid #666;color:#000} .sp-replacer.sp-disabled{cursor:default;border-color:silver;color:silver} .sp-dd{position:absolute;font-size:10px;right:0;top:0;bottom:0;padding:0 1px;line-height:22px;background-color:#fff;border-left: 1px solid #aaa;} .sp-preview{position:relative;width:100%;height:100%;float:left;z-index:0} .sp-preview-inner{transition:background-color .2s} .sp-preview-inner.sp-clear-display{display:none} .sp-palette .sp-thumb-el{width:16px;height:16px;margin:3px;border:none;border-radius:3px} .sp-container button{border-radius:3px;border:none;background:0 0;line-height:1;padding:0 8px;height:25px;text-transform:capitalize;text-align:center;vertical-align:middle;cursor:pointer;color:#606c72;font-weight:700} .sp-container button.sp-choose{background-color:#3cab3b;color:#fff;margin-left:5px} .sp-container button:hover{opacity:.8} .sp-container button.sp-palette-toggle{width:100%;background-color:#f3f3f3;margin:0} .sp-palette span.sp-thumb-active,.sp-palette span:hover{border-color:#000} .sp-alpha,.sp-preview,.sp-thumb-el{position:relative;background-image:url(${IMG_ICON_ALPHA})} .sp-alpha-inner,.sp-preview-inner,.sp-thumb-inner{display:block;position:absolute;top:0;left:0;bottom:0;right:0} .sp-palette .sp-thumb-inner{border-radius:3px;background-position:50% 50%;background-repeat:no-repeat} .sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner{background-image:url(${IMG_ICON_CHECK_BLACK})} .sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner{background-image:url(${IMG_ICON_CHECK_WHITE})} .sp-clear-display{background-repeat:no-repeat;background-position:center;background-image:url(${IMG_ICON_BLOCK})} ` } /** * 自动翻页模块 * @name autoPage * @description 此模块提供了脚本自动翻页的功能 * 提供一个高级配置可以设置自动翻页的检测阈值 */ const autoPage = { name: 'autoPage', settings: [{ type: 'normal', key: 'autoPage', default: true, title: '自动翻页', menu: 'right' }], $window: $(window), initFunc: function () { script.setting.normal.autoPage && $('body').addClass('hld__reply-fixed') }, renderAlwaysFunc: function () { const _this = this if(script.setting.normal.autoPage) { if($('#hld__next_page').length > 0) return $('#pagebbtm>.stdbtn[hld-auto-page!=ok] td').each(function(){ if($(this).children('a').text() == '>') { $(this).children('a').attr('id', 'hld__next_page') _this.$window.on('scroll.autoPage', function(){ if ($(document).scrollTop() != 0 && (Math.ceil($(document).scrollTop()) + $(window).height() >= ($(document).height() - 20))) { if($('#hld__next_page').length > 0) { document.getElementById('hld__next_page').click() $('#hld__next_page').removeAttr('id') _this.$window.off('scroll.autoPage') } } }) } }) $('#pagebbtm>.stdbtn').attr('hld-auto-page', 'ok') } } } /** * 关键字屏蔽模块 * @name keywordsBlock * @description 此模块提供了关键字屏蔽功能 * 提供一个高级配置可以设置是否过滤标题 */ const keywordsBlock = { name: 'keywordsBlock', settings: [{ type: 'normal', key: 'keywordsBlock', default: true, title: '关键字屏蔽', menu: 'right', extra: { type: 'button', label: '关键字管理', id: 'hld__keywords_manage' } }, { type: 'advanced', key: 'kwdBlockContent', default: 'ALL', options: [{ label: '标题跟正文', value: 'ALL' }, { label: '仅标题', value: 'TITLE' }, { label: '仅正文', value: 'BODY' }], title: '关键字屏蔽方式', desc: '此配置表示关键字的屏蔽方式', menu: 'right' }], keywordsList: [], initFunc: function () { const _this = this // 同步本地数据 const localKeywordsList = window.localStorage.getItem('hld__NGA_keywords_list') try { localKeywordsList && (_this.keywordsList = JSON.parse(localKeywordsList)) } catch { localKeywordsList && (_this.keywordsList = localKeywordsList.split(',')) window.localStorage.setItem('hld__NGA_keywords_list', JSON.stringify(_this.keywordsList)) } // 添加到导入导出配置 script.getModule('backupModule').addItem({ title: '关键字列表', writeKey: 'keywords_list', valueKey: 'keywordsList', module: this }) /** * Bind:Click * 管理弹窗面板 */ $('body').on('click', '#hld__keywords_manage', function () { if($('#hld__keywords_panel').length > 0) return $('#hld__setting_cover').append(`
×

屏蔽关键字

一行一条

`) $('#hld__keywords_list_textarea').val(_this.keywordsList.join('\n')) }) /** * Bind:Click * 保存关键字 */ $('body').on('click', '#hld__save_keywords', function () { let keywordsList = $('#hld__keywords_list_textarea').val().split('\n') keywordsList = _this.removeBlank(keywordsList) keywordsList = _this.uniq(keywordsList) _this.keywordsList = keywordsList window.localStorage.setItem('hld__NGA_keywords_list', JSON.stringify(_this.keywordsList)) $('.hld__list-panel').remove() script.popMsg('保存成功,刷新页面生效') }) }, renderThreadsFunc: function ($el) { const title = $el.find('.c2>a').text() if ((script.setting.advanced.kwdBlockContent === 'ALL' || script.setting.advanced.kwdBlockContent === 'TITLE') && script.setting.normal.keywordsBlock && this.keywordsList.length > 0) { for (let keyword of this.keywordsList) { if (title.includes(keyword)) { script.printLog(`关键字屏蔽:标题:${title} 连接:${$el.find('.c2>a').attr('href')}`) $el.remove() break } } } }, renderFormsFunc: function ($el) { const _this = this if (script.setting.normal.keywordsBlock && this.keywordsList.length > 0 && (script.setting.advanced.kwdBlockContent === 'ALL' || script.setting.advanced.kwdBlockContent === 'BODY')) { const $postcontent = $el.find('.postcontent') const $postcontentClone = $postcontent.clone() const consoleLog = (text) => script.printLog(`关键字屏蔽:内容:${text}`) let postcontentQuote = '' let postcontentText = '' if ($postcontent.find('.quote').length > 0) { $postcontentClone.find('.quote').remove() let postcontentText = $postcontent.find('.quote').text() const endIndex = postcontentText.indexOf(')') postcontentQuote = postcontentText.substring(endIndex + 1) } postcontentText = $postcontentClone.text() let blockCount = 0 for (let keyword of this.keywordsList) { if (postcontentText && postcontentText.includes(keyword)) { consoleLog(postcontentText) $el.remove() blockCount += 1 break } if (postcontentQuote && postcontentQuote.includes(keyword)) { consoleLog(postcontentQuote) blockCount += 1 $postcontent.find('.quote').remove() } } const $commentCList = $el.find('.comment_c') if ($commentCList.length > 0) { let postcontentReply = '' $commentCList.each(function () { let postcontentReplyText = $el.find('.ubbcode').text() const end_index = postcontentReplyText.indexOf(')') postcontentReply = postcontentReplyText.substring(end_index + 1) for (let keyword of _this.keywordsList) { if (postcontentReply && postcontentReply.includes(keyword)) { consoleLog(postcontentReply) blockCount += 1 $(this).remove() } } }) } } }, /** * 列表去空 * @method removeBlank * @param {Array} array 列表 * @return {Array} 处理后的列表 */ removeBlank: function (array) { let r = [] array.map(function (val, index) { if (val !== '' && val != undefined) { r.push(val) } }); return r }, /** * 列表去重 * @method uniq * @param {Array} array 列表 * @return {Array} 处理后的列表 */ uniq: function (array) { return [...new Set(array)] }, style: ` #hld__keywords_panel {width:182px;} #hld__keywords_panel .hld__list-c {width:100%;} ` } /** * 黑名单标记模块 * @name markAndBan * @description 此模块提供了黑名单屏蔽功能,标签标记功能 * 提供高级配置可以设置标记/备注风格 * 提供高级配置可以设置功能面板显示方式 * 提供高级配置可以设置黑名单屏蔽策略 */ const markAndBan = { name: 'markAndBan', settings: [{ type: 'normal', key: 'markAndBan', default: true, title: '拉黑/标签功能', menu: 'right', extra: { type: 'button', label: '名单管理', id: 'hld__list_manage' } }, { type: 'advanced', key: 'classicRemark', default: false, title: '经典备注风格', desc: '此配置表示标记功能的风格显示\n选中时:v2.9及以前的备注风格(仿微博),此风格不能更改颜色\n取消时:新版标记风格', menu: 'right' }, { type: 'advanced', key: 'autoHideBanIcon', default: false, title: '按需显示标注拉黑按钮', desc: '选中时:默认隐藏标注与拉黑按钮, 当鼠标停留区域时, 才会显示\n取消时:一直显示', menu: 'right' }, { type: 'advanced', key: 'banStrictMode', default: 'HIDE', options: [{ label: '屏蔽', value: 'HIDE' }, { label: '删除', value: 'REMOVE' }, { label: '全部删除', value: 'ALL' }], title: '拉黑模式', desc: '此配置表示拉黑某人后对帖子的屏蔽策略\n屏蔽:保留楼层, 仅会屏蔽用户的回复\n删除:将会删除楼层\n全部删除: 回复被拉黑用户的回复也会被删除', menu: 'right' }], banList: [], markList: [], initFunc: function () { const _this = this // 读取本地数据 const localBanList = window.localStorage.getItem('hld__NGA_ban_list') try { localBanList && (_this.banList = JSON.parse(localBanList)) } catch { window.localStorage.setItem('hld__NGA_ban_list_bak', localBanList) window.localStorage.removeItem('hld__NGA_ban_list') script.throwError('【NGA-Script】无法加载黑名单列表,数据解析失败\n黑名单已清空,之前的数据已经备份到hld__NGA_ban_list_bak\n请在控制台中的localStorage中查看') } const localMarkList = window.localStorage.getItem('hld__NGA_mark_list') try { localMarkList && (_this.markList = JSON.parse(localMarkList)) } catch { window.localStorage.setItem('hld__NGA_mark_list_bak', localMarkList) window.localStorage.removeItem('hld__NGA_mark_list') script.throwError('【NGA-Script】无法加载标记列表,数据解析失败\n标记列表已清空,之前的数据已经备份到hld__NGA_mark_list_bak\n请在控制台中的localStorage中查看') } // 添加到导入导出配置 script.getModule('backupModule').addItem({ title: '黑名单列表', writeKey: 'ban_list', valueKey: 'banList', module: this }) script.getModule('backupModule').addItem({ title: '标记名单列表', writeKey: 'mark_list', valueKey: 'markList', module: this }) // 拉黑标签-名单 if (script.setting.normal.markAndBan) { /** * Bind:Click * 操作按钮点击事件 */ $('body').on('click', '.hld__extra-icon', function () { const type = $(this).data('type') const name = $(this).data('name') const uid = $(this).data('uid') + '' $('.hld__dialog').length > 0 && $('.hld__dialog').remove() if (type == 'ban') { _this.banlistPopup({ type: 'confirm', name, uid, top: $(this).offset().top+20, left: $(this).offset().left-10 }) } if (type == 'mark') { _this.userMarkPopup({ name, uid, top: $(this).offset().top+20, left: $(this).offset().left-10 }) } }) /** * Bind:Click * 屏蔽按钮 */ $('body').on('click', '.hld__banned-block', function(){ if ($(this).parent().hasClass('quote')) { $(this).parent().prev().show() $(this).parent().hide() } else { $(this).prev().show() $(this).hide() } }) /** * Bind:Click * 名单管理 */ $('body').on('click', '#hld__list_manage', function () { if($('#hld__banlist_panel').length > 0) return $('#hld__setting_cover').append(`
×
简易模式原始数据

黑名单

用户名UID操作

标签名单

用户名UID标签数操作

黑名单

查看数据结构

标签名单

查看数据结构

`) /** * Bind:Click * 切换选项卡 */ $('body').on('click', '.hld__tab-header > span', function(){ $('.hld__tab-header > span, .hld__tab-content').removeClass('hld__table-active') $(this).addClass('hld__table-active') $('.hld__tab-content').eq($(this).index()).addClass('hld__table-active') }) /** * Bind:Click * 移除黑名单 */ $('body').on('click', '.hld__bl-del', function(){ const index = $(this).data('index') _this.banList.splice(index, 1) window.localStorage.setItem('hld__NGA_ban_list', JSON.stringify(_this.banList)) _this.reloadBanlist() }) /** * Bind:Click * 添加黑名单 */ $('body').on('click', '#hld__banlist_add_btn', function(){ _this.banlistPopup({ type: 'add', name: $(this).data('name'), uid: $(this).data('uid'), top: $(this).offset().top + 30, left: $(this).offset().left - 5, callback: () => {_this.reloadBanlist()} }) }) /** * Bind:Click * 保存黑名单 */ $('body').on('click', '#hld__save_banlist', function(){ const banList = $('#hld__ban_list_textarea').val() const markList = $('#hld__mark_list_textarea').val() try { _this.banList = JSON.parse(banList) window.localStorage.setItem('hld__NGA_ban_list', banList) _this.reloadBanlist() } catch { script.popMsg('黑名单数据有误!', 'err') return } try { _this.markList = JSON.parse(markList) window.localStorage.setItem('hld__NGA_mark_list', markList) _this.reloadMarklist() } catch { script.popMsg('标记单数据有误!', 'err') return } script.popMsg('数据已成功') }) /** * Bind:Click * 修改标记 */ $('body').on('click', '.hld__ml-edit', function(){ const name = $(this).data('name') const uid = $(this).data('uid') + '' _this.userMarkPopup({ name, uid, top: $(this).offset().top + 30, left: $(this).offset().left - 5, callback: () => {_this.reloadMarklist()} }) }) /** * Bind:Click * 删除标记 */ $('body').on('click', '.hld__ml-del', function(){ const index = $(this).data('index') _this.markList.splice(index, 1) window.localStorage.setItem('hld__NGA_mark_list', JSON.stringify(_this.markList)) _this.reloadMarklist() }) /** * Bind:Click * 添加标记 */ $('body').on('click', '#hld__marklist_add_btn', function(){ _this.userMarkPopup({ type: 'add', name: $(this).data('name'), uid: $(this).data('uid'), top: $(this).offset().top + 30, left: $(this).offset().left - 5, callback: () => {_this.reloadMarklist()} }) }) //重载名单 _this.reloadBanlist() _this.reloadMarklist() }) } }, renderThreadsFunc: function($el) { const title = $el.find('.c2>a').text() const uid = ($el.find('.author').attr('href') && $el.find('.author').attr('href').indexOf('uid=') > -1) ? $el.find('.author').attr('href').split('uid=')[1] + '' : '' const name = $el.find('.author').text() if (script.setting.normal.markAndBan) { const banUser = this.getBanUser({name, uid}) //黑名单屏蔽 if (this.banList.length > 0 && banUser) { script.printLog(`黑名单屏蔽:标题:${title} 连接:${$el.find('.c2>a').attr('href')}`) $el.parents('tbody').remove() } } }, renderFormsFunc: function($el) { const _this = this if (script.setting.normal.markAndBan) { // 插入操作面板 const currentUid = $el.find('[name=uid]').text() + '' $el.find('.small_colored_text_btn.block_txt_c2.stxt').each(function () { let currentName = '' if ($(this).parents('td').prev('td').html() == '') { currentName = $(this).parents('table').prev('.posterinfo').children('.author').text() } else { currentName = $(this).parents('td').prev('td').find('.author').text() } currentName.endsWith('[楼主]') && (currentName = currentName.substr(0, currentName.length - 4)) const mbDom = `` script.setting.advanced.autoHideBanIcon ? $(this).after(`${mbDom}`) : $(this).append(mbDom) }) // 标记DOm $el.find('a.b').each(function () { const uid = ($(this).attr('href') && $(this).attr('href').indexOf('uid=') > -1) ? $(this).attr('href').split('uid=')[1] + '' : '' let name = '' if ($(this).find('span.hld__post-author').length > 0 || $(this).find('span.hld__remark').length > 0) { const $a = $(this).clone() $a.find('span.hld__post-author, span.hld__remark').remove() name = $a.text() } else { name = $(this).attr('hld-mark-before-name') || $(this).text().replace('[', '').replace(']', '') } const banUser = _this.getBanUser({name, uid}) if (banUser) { //拉黑用户实现 if (script.setting.advanced.banStrictMode == 'HIDE') { if ($(this).hasClass('author')) { if ($(this).parents('div.comment_c').length > 0) { $(this).parents('div.comment_c').find('.ubbcode').hide() $(this).parents('div.comment_c').find('.ubbcode').after('此用户在你的黑名单中,已屏蔽其言论,点击查看') } else { $(this).parents('.forumbox.postbox').find('.c2 .postcontent').hide() $(this).parents('.forumbox.postbox').find('.c2 .postcontent').after('此用户在你的黑名单中,已屏蔽其言论,点击查看') } } else { if (!$(this).parent().is(':hidden')) { $(this).parent().hide() $(this).parent().after('
此用户在你的黑名单中,已屏蔽其言论,点击查看
') } } } else if (script.setting.advanced.banStrictMode == 'ALL') { if ($(this).parents('div.comment_c').length > 0) $(this).parents('div.comment_c').remove() else $(this).parents('.forumbox.postbox').remove() } else { if ($(this).hasClass('author')) { if ($(this).parents('div.comment_c').length > 0) $(this).parents('div.comment_c').remove() else $(this).parents('.forumbox.postbox').remove() } else { $(this).parent().html('此用户在你的黑名单中,已删除其言论') } } script.printLog(`黑名单屏蔽:用户:${name}, UID:${uid}`) } if(script.setting.advanced.classicRemark) { //经典备注风格 const userMarks = _this.getUserMarks({name, uid}) if (userMarks) { let f = [] userMarks.marks.forEach(e => f.push(e.mark)) $(this).attr('hld-mark-before-name', name).append(` (${f.join(', ')}) `) } }else { //新版标签风格 const userMarks = _this.getUserMarks({name, uid}) if(userMarks) { const $el = $(this).parents('.c1').find('.clickextend') let marksDom = '' userMarks.marks.forEach(item => marksDom += `${item.mark}`); $el.before(`
标签: ${marksDom}
`) } } }) } }, /** * 黑名单弹窗 * @method banlistPopup * @param {Object} setting 设置项 * @param {String} setting.name 用户昵称 * @param {String} setting.uid UID * @param {String} setting.type 模式 * @param {Number} setting.top pos.top位置 * @param {Number} setting.left pos.left 位置 * @param {Function} setting.callback 回调函数 */ banlistPopup: function (setting) { const _this = this $('.hld__dialog').length > 0 && $('.hld__dialog').remove() const retainWord = [':', '(', ')', '&', '#', '^', ','] let $banDialog = $(``) if (setting.type == 'confirm') { $banDialog.find('#container_dom').append(`
您确定要拉黑用户${setting.name}吗?
`) let $okBtn = $('') $okBtn.click(function(){ const banObj = {name: setting.name, uid: setting.uid} !_this.getBanUser(banObj) && _this.banList.push(banObj) window.localStorage.setItem('hld__NGA_ban_list', JSON.stringify(_this.banList)) $('.hld__dialog').remove() script.popMsg('拉黑成功,重载页面生效') }) $banDialog.find('.hld__dialog-buttons').append($okBtn) }else if (setting.type == 'add') { $banDialog.find('#container_dom').append(`
添加用户:
`) let $okBtn = $('') $okBtn.click(function(){ const name = $banDialog.find('#hld__dialog_add_name').val().trim() const uid = $banDialog.find('#hld__dialog_add_uid').val().trim() + '' if (!name && !uid) { script.popMsg('UID与用户名必填一个,其中UID权重较大', 'err') return } !_this.getBanUser({name, uid}) && _this.banList.push({name, uid}) window.localStorage.setItem('hld__NGA_ban_list', JSON.stringify(_this.banList)) $('.hld__dialog').remove() setting.callback() }) $banDialog.find('.hld__dialog-buttons').append($okBtn) } $('body').append($banDialog) }, /** * 获取黑名单用户 * @method getBanUser * @param {Object} banObj 黑名单对象 * @return {Object|null} 获取的用户对象 */ getBanUser: function (banObj) { const _this = this for (let u of _this.banList) { if ((u.uid && banObj.uid && u.uid == banObj.uid) || (u.name && banObj.name && u.name == banObj.name)) { if ((!u.uid && banObj.uid) || (!u.name && banObj.name)) { u.uid = banObj.uid + '' || '' u.name = banObj.name || '' window.localStorage.setItem('hld__NGA_ban_list', JSON.stringify(_this.banList)) } return u } } return null }, /** * 重新渲染黑名单列表 * @method reloadBanlist */ reloadBanlist: function () { const _this = this $('#hld__banlist').empty() _this.banList.forEach((item, index) => $('#hld__banlist').append(`${item.name}${item.uid}`)) $('#hld__ban_list_textarea').val(JSON.stringify(_this.banList)) }, /** * 重新渲染标签列表 * @method reloadMarklist */ reloadMarklist: function () { const _this = this $('#hld__marklist').empty() _this.markList.forEach((user_mark, index) => { $('#hld__marklist').append(`${user_mark.name}${user_mark.uid}${user_mark.marks.length}`) }) $('#hld__mark_list_textarea').val(JSON.stringify(_this.markList)) }, /** * 标记弹窗 * @method userMarkPopup * @param {Object} setting 设置项 * @param {String} setting.name 用户名 * @param {String} setting.uid UID * @param {String} setting.type 模式 * @param {Number} setting.top pos.top位置 * @param {Number} setting.left pos.left 位置 * @param {Function} setting.callback 回调函数 */ userMarkPopup: function (setting) { const _this = this $('.hld__dialog').length > 0 && $('.hld__dialog').remove() const retain_word = [':', '(', ')', '&', '#', '^', ','] let $markDialog = $(`
× ${setting.type == 'add' ? `
添加用户:
` : ''}
标签文字背景操作
`) const insertRemarkRow = (r='', t='#ffffff', b='#1f72f1', n=true) => { let $tr = $(` `) $tr.find('.hld__mark-del').click(function(){$(this).parents('tr').remove()}) $tr.find('.hld__dialog-color-picker').spectrum(script.getModule('authorMarkColor').colorPickerConfig) $markDialog.find('#hld__mark_body').append($tr) n && $tr.find('.hld__mark-mark').focus() } //恢复标签 const existMark = _this.getUserMarks({name: setting.name, uid: setting.uid}) existMark !== null && existMark.marks.forEach(item => insertRemarkRow(item.mark, item.text_color, item.bg_color, false)) let $addBtn = $('') $addBtn.click(() => insertRemarkRow()) $markDialog.find('.hld__dialog-buttons').append($addBtn) let $okBtn = $('') $okBtn.click(function(){ let userMarks = {marks: []} if (setting.type == 'add') { userMarks.name = $markDialog.find('#hld__dialog_add_name').val().trim() userMarks.uid = $markDialog.find('#hld__dialog_add_uid').val().trim() + '' } else { userMarks.name = setting.name userMarks.uid = setting.uid + '' } if (!userMarks.name && !userMarks.uid) { script.popMsg('UID与用户名必填一个,其中UID权重较大', 'err') return } $('#hld__mark_body > tr').each(function(){ const mark = $(this).find('.hld__mark-mark').val().trim() const textColor = $(this).find('.hld__mark-text-color').val() const bgColor = $(this).find('.hld__mark-bg-color').val() if(mark) { userMarks.marks.push({mark, text_color: textColor, bg_color: bgColor}) } }) if (setting.type == 'add' && userMarks.marks.length == 0) { script.popMsg('至少添加一个标签内容', 'err') return } _this.setUserMarks(userMarks) script.popMsg('保存成功,重载页面生效') $('.hld__dialog').remove() setting.callback() }) $markDialog.find('.hld__dialog-buttons').append($okBtn) $('body').append($markDialog) $('.hld__dialog-color-picker').spectrum(script.getModule('authorMarkColor').colorPickerConfig) }, /** * 获取用户标签对象 * @method getUserMarks * @param {String} uid UID * @param {String} user 用户名 * @return {Object|null} 标签对象 */ getUserMarks: function (user) { const _this = this const check = _this.markList.findIndex(v => (v.uid && user.uid && v.uid == user.uid) || (v.name && user.name && v.name == user.name)) if(check > -1) { let userMark = _this.markList[check] if ((!userMark.uid && user.uid) || (!userMark.name && user.name)) { userMark.uid = user.uid + '' || '' userMark.name = user.name || '' window.localStorage.setItem('hld__NGA_mark_list', JSON.stringify(_this.markList)) } return _this.markList[check] } else { return null } }, /** * 保存标签 * @method setUserMarks * @param {Object} userMarks 标签对象 */ setUserMarks: function (userMarks) { // 检查是否已有标签 const _this = this const check = _this.markList.findIndex(v => (v.uid && userMarks.uid && v.uid == userMarks.uid) || (v.name && userMarks.name && v.name == userMarks.name)) if(check > -1) { if (userMarks.marks.length == 0) { _this.markList.splice(check, 1) } else { _this.markList[check] = userMarks } }else { _this.markList.push(userMarks) } window.localStorage.setItem('hld__NGA_mark_list', JSON.stringify(_this.markList)) }, style: ` #hld__setting {color:#6666CC !important;cursor:pointer;} .hld__list-panel {position:fixed;background:#fff8e7;padding:15px 20px;border-radius:10px;box-shadow:0 0 10px #666;border:1px solid #591804;z-index:9999;} #hld__banlist_panel {width:500px;} #hld__keywords_panel {width:182px;} .hld__extra-icon-box {padding: 5px 5px 5px 0;opacity: 0;transition: all ease .2s;} .hld__extra-icon-box:hover {opacity: 1;} .hld__extra-icon {position: relative;padding:0 2px;background-repeat:no-repeat;background-position:center;} .hld__extra-icon svg {width:10px;height:10px;vertical-align:-0.15em;fill:currentColor;overflow:hidden;cursor:pointer;} .hld__extra-icon:hover {text-decoration:none;} span.hld__remark {color:#666;font-size:0.8em;} span.hld__banned {color:#ba2026;} span.hld__banned-block:hover {text-decoration: underline;cursor: pointer;} .hld__dialog{position:absolute;padding-right:35px} .hld__dialog>div{line-height:30px} .hld__dialog:before{position:absolute;content:' ';width:10px;height:10px;background-color:#fff6df;left:10px;transform:rotate(45deg)} .hld__dialog-sub-top:before{top:-6px;border-top:1px solid #591804;border-left:1px solid #591804} .hld__dialog-sub-bottom:before{bottom:-5px;border-bottom:1px solid #591804;border-right:1px solid #591804} .hld__dialog-buttons{display:flex;justify-content:flex-end!important;margin-top:10px} .hld__dialog-buttons>button{cursor:pointer} .hld__dialog-user{font-size:1.5em;color:red;margin:0 5px} .hld__dialog input[type=text]{width:100px;margin-right:15px} .hld__dialog-mark-table td{padding-bottom:3px} .hld__dialog-mark-table button{padding:0 6px;margin:0;height:20px;line-height:20px;width:20px;text-align:center;cursor:pointer} .hld__tab-content {display:flex;justify-content:space-between;flex-wrap: wrap;} .hld__table-keyword {margin-top:10px;width:200px;} .hld__table-keyword tr td:last-child {text-align:center;} .hld__table-keyword input[type=text] {width:48px;text-transform:uppercase;text-align:center;} .hld__tab-header{height:40px} .hld__tab-header>span{margin-right:10px;padding:5px;cursor:pointer} .hld__tab-header .hld__table-active,.hld__tab-header>span:hover{color:#591804;font-weight:700;border-bottom:3px solid #591804} .hld__tab-content{display:none} .hld__tab-content.hld__table-active{display:flex} .hld__marks-container>span{padding:1px 5px;border-radius:3px;margin-right:5px;color:#fff;background-color:#1f72f1} .hld__table{table-layout:fixed;border-top:1px solid #ead5bc;border-left:1px solid #ead5bc} .hld__table-banlist-buttons{margin-top:10px} .hld__table thead{background:#591804;border:1px solid #591804;color:#fff} .hld__scroll-area{position:relative;height:200px;overflow:auto;border:1px solid #ead5bc} .hld__scroll-area::-webkit-scrollbar{width:6px;height:6px} .hld__scroll-area::-webkit-scrollbar-thumb{border-radius:10px;box-shadow:inset 0 0 5px rgba(0,0,0,.2);background:#591804} .hld__scroll-area::-webkit-scrollbar-track{box-shadow:inset 0 0 5px rgba(0,0,0,.2);border-radius:10px;background:#ededed} .hld__table td,.hld__table th{padding:3px 5px;border-bottom:1px solid #ead5bc;border-right:1px solid #ead5bc;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .hld__us-action{display: inline-block;width:18px;height:18px;margin:0 3px;} .hld__us-action:hover{opacity:.8} .hld__us-edit{background-size:20px;background-image:url("${SVG_ICON_EDIT}")} .hld__us-del{background-image:url("${SVG_ICON_DEL}")} ` } /** * 护眼模式 * @name eyeCareMode * @description 此模块提供了护眼模式(绿色) */ const eyeCareMode = { name: 'eyeCareMode', setting: { type: 'normal', key: 'eyeCareMode', default: false, title: '护眼模式', desc: 'NGA自带的界面色调会与此功能有一定冲突\n使用前请先将NGA的界面色调设置为默认', menu: 'left' }, mainColor: '#cce8cc', // 主背景颜色 textColor: '#10273f', //文字颜色 buttonColor: '#c7edcc', // 按钮颜色 borderColor: '#ffffff', // 边框颜色 initFunc: function () { script.setting.normal.eyeCareMode && $('body').addClass('hld__eye-care') }, asyncStyle: function () { return ` body.hld__eye-care, .hld__eye-care #msg_block_c .menu a, #msg_block_c .pager a, .hld__eye-care .nav_link, .hld__eye-care button.hld__btn:hover {color: ${this.textColor} !important;} .hld__eye-care body, .hld__eye-care .stdbtn, .hld__eye-care .stdbtn .innerbg, .hld__eye-care .stdbtn a, .hld__eye-care .nav_root, .hld__eye-care .nav_link, .hld__eye-care .nav_spr, .hld__eye-care .stdbtn a:hover, .hld__eye-care .row2c1, .hld__eye-care .row1c1, .hld__eye-care .c1, .hld__eye-care .c2, .hld__eye-care .c3, .hld__eye-care .c4, .hld__eye-care .catenew, .hld__eye-care .cateblock, .hld__eye-care .forumbox, .hld__eye-care .quote, .hld__eye-care textarea, .hld__eye-care select, .hld__eye-care input, .hld__eye-care #m_posts .white, .hld__eye-care #m_posts .block_txt_c0, .hld__eye-care #m_posts .block_txt_c2, .hld__eye-care .block_txt_c3, .hld__eye-care .block_txt, .hld__eye-care .hld__docker-sidebar, .hld__eye-care .hld__docker-btns > div, .hld__eye-care .forumbox th, .hld__eye-care .contentBlock, .hld__eye-care .catenew .b2, .hld__eye-care .catenew .b3, .hld__eye-care .catenew h2, .hld__eye-care .catenew div, .hld__eye-care .topicrow .c2 > span:first-child, .hld__eye-care .urltip.nobr, .hld__eye-care #hld__setting_panel, .hld__eye-care .hld__list-panel, .hld__eye-care .single_ttip2 .tip_title, .hld__eye-care .single_ttip2 .div2, .hld__eye-care .postBtnPos > div, .hld__eye-care .postBtnPos .stdbtn a, .hld__eye-care .postbtnsc td, .hld__eye-care #mc > div:not(.module_wrap):not(#mainmenu), .hld__eye-care #m_nav > div:not(.nav), .hld__eye-care {background-color: ${this.mainColor} !important;} .hld__eye-care .nav_root, .hld__eye-care .nav_link, .hld__eye-care .nav_spr, .hld__eye-care .stdbtn, .hld__eye-care .quote, .hld__eye-care textarea, .hld__eye-care select, .hld__eye-care input, .hld__eye-care .block_txt_c2, .hld__eye-care .block_txt_c3, .hld__eye-care .hld__docker-btns>div, .hld__eye-care .r_container, .hld__eye-care .forumbox .postrow .stat {border:1px solid ${this.borderColor} !important;} .hld__eye-care .b .block_txt, .hld__eye-care .block_txt.block_txt_c0 {color: #1a3959 !important;padding:0 !important;} .hld__eye-care .forumbox.postbox {border-bottom: 2px solid ${this.borderColor} !important;border: none !important;} .hld__eye-care .r_bar {background-color: ${this.borderColor};} .hld__eye-care .forumbox .postrow .sigline, .hld__eye-care #m_posts .block_txt_c0 {color: ${this.borderColor} !important;border-color: ${this.borderColor} !important;} .hld__eye-care .nav_root, .hld__eye-care .invert, .hld__eye-care #mainmenu .stdbtn .half, .hld__eye-care .catenew .invert .uitxt1, .hld__eye-care .catenew .invert .uitxt3 {color:#591804;} .hld__eye-care:not(.hld__excel-body) #mainmenu {border-bottom: 1px solid ${this.borderColor} !important;} .hld__eye-care #m_posts, .hld__eye-care #toptopics, .hld__eye-care #topicrows, .hld__eye-care #mc > div:not(.module_wrap):not(#mainmenu), .hld__eye-care #msg_block_c .subblock {box-shadow:none;border-color: ${this.borderColor} !important;} .hld__eye-care .stdbtn a, .hld__eye-care .hld__advanced-setting, .hld__eye-care .hld__docker-sidebar {border-color: ${this.borderColor};} .hld__eye-care .block_txt.block_txt_c3 {border:none !important;} .hld__eye-care button, .hld__eye-care .hld__setting-close, .hld__eye-care .colored_text_btn, .hld__eye-care .rep.block_txt_big {border: 1px solid ${this.borderColor} !important;background: ${this.buttonColor} !important;} .hld__eye-care #toppedtopic table, .hld__eye-care .single_ttip2 .tip_title, .hld__eye-care .collapse_btn {border-color: ${this.borderColor} !important;} .hld__eye-care .apd {color: ${this.borderColor} !important;} .hld__eye-care .forumbox td:not(.c0) {border-color: ${this.borderColor} !important;border-bottom: 1px solid ${this.borderColor};border-right: 1px solid ${this.borderColor};} .hld__eye-care .c4 {border-right:none !important;} /* Excel 适配 */ .hld__eye-care.hld__excel-body .hld__quote-box, .hld__eye-care.hld__excel-body #m_pbtnbtm td a {background: ${this.mainColor};} .hld__eye-care.hld__excel-body #postbbtm .stdbtn, .hld__eye-care.hld__excel-body #postbbtm td a {background: #FFF !important;} .hld__eye-care.hld__excel-body .nav_root, .hld__eye-care.hld__excel-body .nav_spr,.hld__eye-care.hld__excel-body .nav_link, .hld__eye-care.hld__excel-body #mainmenu .stdbtn, .hld__eye-care.hld__excel-body #mainmenu .innerbg, .hld__eye-care.hld__excel-body #mainmenu .stdbtn a {background: none !important;border: none !important;} .hld__eye-care.hld__excel-body #mainmenu .mmdefault.cell input {background-color:#ededed !important;border-color: #c9d0dc !important;} ` } } /** * 字体大小调整 * @name fontResize * @description 此模块提供了调整字体大小的功能 */ const fontResize = { name: 'fontResize', setting: { type: 'advanced', key: 'fontResize', default: 12, title: '字体大小调整', desc: '字体大小调整,单位为像素(px),初始值是12', menu: 'left' }, initFunc: function () { const fontResizeInput = script.setting.advanced.fontResize try { const fontSize = parseInt(fontResizeInput) if (fontSize && fontSize != 12) { $('body').css('font-size', fontSize + 'px') } } catch { script.printLog(`字体大小的值${script.setting.advanced.fontResize}无效,不是一个有效的数字`) } } } /** * 扩展坞模块 * @name extraDocker * @description 此模块提供了一个悬浮的扩展坞,来添加某些功能 * 目前添加的功能有: * 返回顶部:无跳转返回当前页面的第一页/刷新当页 * 跳转尾页:跳转到当前帖子的尾页 */ const extraDocker = { name: 'extraDocker', settings: [{ shortCutCode: 84, // T key: 'backTop', title: '返回顶部' }, { shortCutCode: 66, // B key: 'backBottom', title: '跳转尾页' }], initFunc: function () { const _this = this const $dockerDom = $(`
`) $('body').append($dockerDom) /** * Bind:Click * 按钮点击事件 */ $('body').on('click', '.hld__docker-btns>div', function () { const type = $(this).data('type') if (type == 'TOP') { const $nav_link = $('#m_nav a.nav_link') if ($nav_link.length > 0) { $nav_link[$nav_link.length-1].click() } } if (type == 'BOTTOM') { let queryset = _this.getQuerySet() queryset.page = 9999 let search = '' for (let key in queryset) { search += `${search == '' ? '?' : '&'}${key}=${queryset[key]}` } window.location.href = `${window.location.origin}${window.location.pathname}${search}` } }) }, renderAlwaysFunc: function (script) { (script.isThreads() || script.isForms()) ? $('.hld__docker').show() : $('.hld__docker').hide() }, shortcutFunc: { backTop: function () { $('#hld__jump_top').click() script.popNotification('返回顶部') }, backBottom: function () { $('#hld__jump_bottom').click() script.popNotification('最后一页') } }, /** * 获取URL参数对象 * @method getQuerySet * @return {Object} 参数对象 */ getQuerySet: function () { let queryList = {} let url = decodeURI(window.location.search.replace(/&/g, "&")) url.startsWith('?') && (url = url.substring(1)) url.split('&').forEach(item => { let t = item.split('=') if (t[0] && t[1]) { queryList[t[0]] = t[1] } }) return queryList }, style: ` .hld__docker{position:fixed;height:80px;width:30px;bottom:135px;right:0;transition:all ease .2s} .hld__docker:hover{width:150px;height:200px;bottom:80px} .hld__docker-sidebar{background:#0f0;position:fixed;height:50px;width:20px;bottom:150px;right:0;display:flex;justify-content:center;align-items:center;background:#fff6df;border:1px solid #591804;box-shadow:0 0 5px #444;border-right:none;border-radius:5px 0 0 5px} .hld__excel-body .hld__docker-sidebar{background:#fff;border:1px solid #bbb} .hld__docker-btns{position:absolute;top:0;left:50px;bottom:0;right:50px;display:flex;justify-content:center;align-items:center;flex-direction:column} .hld__docker .hld__docker-btns>div{opacity:0} .hld__docker:hover .hld__docker-btns>div{opacity:1} .hld__docker-btns>div{background:#fff6df;border:1px solid #591804;box-shadow:0 0 5px #444;width:50px;height:50px;border-radius:50%;margin:10px 0;cursor:pointer;display:flex;justify-content:center;align-items:center} .hld__excel-body .hld__docker-btns>div{background:#fff;border:1px solid #bbb} .hld__docker-btns svg{width:30px;height:30px;transition:all ease .2s} .hld__docker-btns svg:hover{width:40px;height:40px} .hld__excel-body .hld__docker-sidebar{background:#fff;border:1px solid #bbb} .hld__excel-body .hld__docker-btns>div{background:#fff;border:1px solid #bbb} ` } /** * 初始化脚本 */ const script = new NGABBSScript() /** * 添加模块 */ script.addModule(defaultStyle) script.addModule(settingPanel) script.addModule(shortCutKeys) script.addModule(backupModule) script.addModule(rewardPanel) script.addModule(dynamicEnable) script.addModule(hideAvatar) script.addModule(hideSmile) script.addModule(hideImage) script.addModule(imgResize) script.addModule(hideSign) script.addModule(hideHeader) script.addModule(excelMode) script.addModule(excelTitle) script.addModule(foldQuote) script.addModule(linkTargetBlank) script.addModule(directLinkJump) script.addModule(imgEnhance) script.addModule(authorMark) script.addModule(authorMarkColor) script.addModule(autoPage) script.addModule(keywordsBlock) script.addModule(markAndBan) script.addModule(eyeCareMode) script.addModule(fontResize) script.addModule(extraDocker) /** * 运行脚本 */ script.run() })();