// ==UserScript== // @name NGA Pins // @namespace https://greasyfork.org/zh-CN/scripts/36246-nga-pins // @version 0.0.9.20180215 // @icon http://bbs.nga.cn/favicon.ico // @description NGA Pins 可将顶部菜单、导航栏、页码栏固定在窗口顶部,亦可通过设置取消其中某项;主帖内容较长时将作者信息固定在主帖左侧(不包含回复) // @author AgLandy // @include /^https?:\/\/(bbs\.ngacn\.cc|nga\.178\.com|bbs\.nga\.cn)/ // @grant none // @license MIT License // @downloadURL none // ==/UserScript== //发布地址:http://bbs.ngacn.cc/read.php?tid=13033636 if(typeof jQuery == 'undefined'){ let s = document.createElement('script'); s.type = 'text/javascript'; s.src = 'https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js'; s.onload = s.onreadystatechange = function(){ if(!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState){ main(jQuery.noConflict()); this.onload = this.onreadystatechange = null; } }; document.head.appendChild(s); } else main(jQuery); function main($Q){ if(!window.commonui) return; var pins = commonui.pins = {}; function testStorage(s){ if(!!s){ try{ s.testkey = 'testvalue'; s.removeItem('testkey'); return true; } catch(e){ return false; } } else return false; } function init(){ let args = {}; if(localStorage.pins) args = JSON.parse(localStorage.pins); else{ args = {a: 56, b: 42, c: 43}; localStorage.pins = JSON.stringify(args); } __SETTING.pins = function(){ this.o = commonui.createCommmonWindow(); this.o._.addContent(null); var $ = window._$; this.o._.addTitle('Pins 设置'); let update = function(t){ if(t.checked) pins.args[t.name] = parseInt(t.value); else pins.args[t.name] = 0; localStorage.pins = JSON.stringify(pins.args); pins.update(); }, z = [['a', '56', '顶部菜单'], ['b','42', '导航栏'], ['c','43', '页码栏']]; for(let i = 0; i < z.length; i++){ let k = $('/input').$0('type','checkbox','checked',0,'name',z[i][0],'value',z[i][1])._.on('click', function(e){update(e.target);}); this.o._.addContent( k, z[i][2], $('/br') ); if(pins.args[z[i][0]]) k._.attr('checked', 1); } this.o._.show(); }; commonui.mainMenu.data[401] = {innerHTML: 'Pins 设置', on: {event: 'click', func: function(){__SETTING.pins();}}, parent: 18}; commonui.mainMenu.data[18].subKeys.push(401); return args; } $Q('