// ==UserScript== // @id mlpchan-anon@scriptish // @name /anon/ anon enforcer // @version 1.0 // @namespace // @author // @description // @include https://mlpchan.net/* // @run-at document-end // ==/UserScript== (function() { /* what the board tells us is name#trip overrides this script, but if the board tells us an empty name, or an empty trip this script overrides that with its full name and full trip if possible. Except on /anon/ depending which boxes are checked. */ if(localStorage.name) { var match = localStorage.name.match(/([^#]+)#?(.*)/); if(match) { if(match[1].length > 0) { GM_setValue('name',match[1]); } if(match[2].length > 0) { GM_setValue('trip',match[2]); } } } var prefs = {}; prefs.name = GM_getValue('name'); prefs.trip = GM_getValue('trip'); function reversePrefs() { var nametrip = null; if(prefs.name) { nametrip = prefs.name; } if(prefs.trip) { if(nametrip) { nametrip += '#'+prefs.trip; } else { nametrip = '#'+prefs.trip; } } if(nametrip) localStorage.name = nametrip; } reversePrefs(); var name; var forms = document.getElementsByTagName('form'); for(var i=0;i 0) { list = list[0]; var links = list.getElementsByClassName("boardlistactive"); for(var i = 0; i < links.length; ++i) { var link = links[i]; if (link.firstChild.nodeValue == 'anon') { anonlink = link; break; } } } else { console.log('No board list found'); } var box = document.createElement('span'); box.style.visibility = 'visible'; box.style.border = 'thick solid red'; if(anonlink) { anonlink.parentNode.insertBefore(box,anonlink.nextSibling); } else { console.warn("Couldn't find link to /anon/"); var body = document.getElementsByTagName('body')[0]; body.insertBefore(box,body.firstChild); } info = {}; function createCheckbox(ident) { var check = document.createElement('input'); check.setAttribute('type','checkbox'); check.setAttribute('title','disable '+ident); check.checked = GM_getValue("disabled."+ident); function update() { if(check.checked) { info[ident] = null; } else { info[ident] = prefs[ident]; } updateInfo(); } update(); check.addEventListener('change',function(e) { GM_setValue("disabled."+ident,check.checked); update(); },true); box.appendChild(check); } createCheckbox('name'); createCheckbox('trip'); })();