-
-
Save agentlame/5970519 to your computer and use it in GitHub Desktop.
test ver of notifier with log spam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Toolbox Notifier | |
| // @namespace http://www.reddit.com/r/toolbox | |
| // @author creesch, agentlame | |
| // @description notifications of messages | |
| // @include http://reddit.com/* | |
| // @include https://reddit.com/* | |
| // @include http://*.reddit.com/* | |
| // @include https://*.reddit.com/* | |
| // @downloadURL http://userscripts.org/scripts/source/172111.user.js | |
| // @version 1.5 | |
| // ==/UserScript== | |
| function tbnoti() { | |
| if (!reddit.logged) return; | |
| // | |
| // preload some generic variables | |
| // | |
| var checkInterval = TBUtils.setting('Notifier', 'checkinterval', 1*60*1000), //default to check every minute for new stuff. | |
| modnotifications = localStorage['Toolbox.Notifier.modnotifications'] || 'on', | |
| messagenotifications = localStorage['Toolbox.Notifier.messagenotifications'] || 'on', | |
| modsubreddits = localStorage['Toolbox.Notifier.modsubreddits'] || 'mod', | |
| unmoderatedsubreddits = localStorage['Toolbox.Notifier.unmoderatedsubreddits'] || 'mod', | |
| shortcuts = localStorage['Toolbox.Notifier.shortcuts'] || '-', | |
| shortcuts2 = JSON.parse(localStorage['Toolbox.Notifier.shortcuts2'] || '{}'), | |
| modbarhidden = TBUtils.setting('Notifier', 'modbarhidden', false), | |
| unmoderatedon = TBUtils.setting('Notifier', 'unmoderatedon', true), | |
| consolidatedmessages = TBUtils.setting('Notifier', 'consolidatedmessages', false), | |
| footer = $('.footer-parent'), | |
| unreadmessagecount = TBUtils.setting('Notifier', 'unreadmessagecount', 0), | |
| modqueuecount = TBUtils.setting('Notifier', 'modqueuecount', 0), | |
| unmoderatedcount = TBUtils.setting('Notifier', 'unmoderatedcount', 0), | |
| unreadpage = location.pathname.match(/\/message\/(?:unread)\/?/), | |
| modmailcount = TBUtils.setting('Notifier', 'modmailcount', 0), | |
| debugMode = TBUtils.setting('Utils', 'debugMode', false), | |
| consoleShowing = false; | |
| // Module settings. | |
| var mmpEnabled = TBUtils.setting('ModMailPro', 'enabled', true), | |
| mbEnabled = TBUtils.setting('ModButton', 'enabled', true), | |
| mteEnabled = TBUtils.setting('ModTools', 'enabled', true), | |
| notesEnabled = TBUtils.setting('UserNotes', 'enabled', true), | |
| dtagEnabled = TBUtils.setting('DomainTagger', 'enabled', true), | |
| configEnabled = TBUtils.setting('TBConfig', 'enabled', true), | |
| stattitEnabled = TBUtils.setting('StattitTab', 'enabled', true); | |
| // MTE settings. | |
| var hideactioneditems = TBUtils.setting('ModTools', 'hideactioneditems', false), | |
| ignoreonapprove = TBUtils.setting('ModTools', 'ignoreonapprove', false), | |
| removalreasons = TBUtils.setting('ModTools', 'removalreasons', true), | |
| commentreasons = TBUtils.setting('ModTools', 'commentreasons', false), | |
| rtscomment = TBUtils.setting('ModTools', 'rtscomment', true), | |
| sortmodsubs = TBUtils.setting('ModTools', 'sortmodsubs', false); | |
| var icon = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHaSURBVDjLlZO7a1NRHMfzfzhIKQ5OHR1ddRRBLA6lg4iT\ | |
| d5PSas37YR56Y2JiHgg21uoFxSatCVFjbl5iNBBiMmUJgWwZhCB4pR9/V4QKfSQdDufF5/v7nu85xwJYprV0Oq0kk8luIpEw4vG48f/eVDiVSikCTobDIePxmGg0yokEBO4OBgNGoxH5fJ5wOHwygVgsZpjVW60WqqqWz\ | |
| bVgMIjf78fn8xlTBcTy736/T7VaJRQKfQoEArqmafR6Pdxu9/ECkUjkglje63Q6NBoNisUihUKBcrlMpVLB6XR2D4df3VQnmRstsWzU63WazSZmX6vV0HWdUqmEw+GY2Gw25SC8dV1l1wrZNX5s3qLdbpPL5fB6vXumZal\ | |
| q2O32rtVqVQ6GuGnCd+HbFnx9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| // | |
| // Mark messages on /unread/ read | |
| if (unreadpage) { | |
| var entries = $('.entry'); | |
| $(entries).click(); | |
| } | |
| // toolbar, this will display all counters, quick links and other settings for the toolbox | |
| var modbar = $('\ | |
| <div id="tb-bottombar" class="tb-toolbar">\ | |
| <a class="tb-bottombar-hide" href="javascript:void(0)"><img src="data:image/png;base64,' + iconhide + '" /></a> \ | |
| <a class="tb-toolbar tb-toolbarsettings" href="javascript:void(0)"><img src="data:image/png;base64,' + icon + '" /></a>\ | |
| <span id="tb-toolbarshortcuts"></span>\ | |
| <span id="tb-toolbarcounters">\ | |
| <a title="no mail" href="http://www.reddit.com/message/inbox/" class="nohavemail" id="tb-mail"></a> \ | |
| <a href="http://www.reddit.com/message/inbox/" class="tb-toolbar" id="tb-mailCount">[0]</a>\ | |
| <a title="modqueue" href="http://www.reddit.com/r/' + modsubreddits + '/about/modqueue" id="tb-modqueue"></a> \ | |
| <a href="http://www.reddit.com/r/' + modsubreddits + '/about/modqueue" class="tb-toolbar" id="tb-queueCount">[0]</a>\ | |
| <a title="modmail" href="http://www.reddit.com/message/moderator/" id="tb-modmail" class="nohavemail"></a>\ | |
| <a href="http://www.reddit.com/message/moderator/" class="tb-toolbar" id="tb-modmailcount">[0]</a>\ | |
| </span>\ | |
| </div>\ | |
| '); | |
| var modbarhid = $('\ | |
| <div id="tb-bottombar-hidden" class="tb-toolbar">\ | |
| <a class="tb-bottombar-unhide" href="javascript:void(0)"><img src="data:image/png;base64,' + iconshow + '" /></a>\ | |
| </div>'); | |
| var $console = $('\ | |
| <div class="tb-debug-window">\ | |
| <div class="tb-debug-header"> Debug console <span class="tb-debug-header-options"><a class="tb-close" id="tb-debug-hide" href="javascript:;">X</a></span></div>\ | |
| <div class="tb-debug-content">\ | |
| <textarea class="tb-debug-console" rows="20" cols="20"></textarea>\ | |
| </div>\ | |
| <div class="tb-debug-footer" comment="for the looks"> </div>\ | |
| </div>\ | |
| '); | |
| $console.appendTo('body').hide(); | |
| $(footer).prepend(modbar); | |
| // if mod counters are on we append them to the rest of the counters here. | |
| if (unmoderatedon) { | |
| $('#tb-bottombar').find('#tb-toolbarcounters').append('\ | |
| <a title="unmoderated" href="http://www.reddit.com/r/' + unmoderatedsubreddits + '/about/unmoderated" id="tb-unmoderated"></a>\ | |
| <a href="http://www.reddit.com/r/' + unmoderatedsubreddits + '/about/unmoderated" class="tb-toolbar" id="tb-unmoderatedcount">[0]</a>\ | |
| '); | |
| } | |
| if (debugMode) { | |
| $('#tb-bottombar').find('#tb-toolbarcounters').prepend('\ | |
| <span><a href="javascript:;" id="tb-toggle-console"><img title="debug console" src="data:image/png;base64,' + iconConsole + '" /></a> </span>\ | |
| '); | |
| var $consoleText = $('.tb-debug-console'); | |
| (function consoleLoop(){ | |
| setTimeout(function(){ | |
| $consoleText.val(TBUtils.log); | |
| consoleLoop(); | |
| }, 500) | |
| })(); | |
| } | |
| // Append shortcuts | |
| $.each(shortcuts2, function(index, value) { | |
| var shortcut = $('<span>- <a href="' + unescape(value) + '">' + unescape(index) + '</a> </span>'); | |
| $(shortcut).appendTo('#tb-toolbarshortcuts'); | |
| }); | |
| $(footer).prepend(modbarhid); | |
| $.log('hi'); | |
| $.log('ello'); | |
| $.log('skipped', true) | |
| function toggleMenuBar(hidden) { | |
| if (hidden) { | |
| $(modbar).hide(); | |
| $(modbarhid).show(); | |
| $console.hide(); // hide the console, but don't change consoleShowing. | |
| } else { | |
| $(modbar).show(); | |
| $(modbarhid).hide(); | |
| if (consoleShowing) $console.show(); | |
| } | |
| TBUtils.setting('Notifier', 'modbarhidden', '', hidden); | |
| } | |
| toggleMenuBar(modbarhidden); | |
| // Show/hide menubar | |
| $('body').delegate('.tb-bottombar-unhide, .tb-bottombar-hide', 'click', function () { | |
| toggleMenuBar($(this).hasClass('tb-bottombar-hide')); | |
| }); | |
| // Show counts on hover | |
| $(modbarhid).hover(function modbarHover(){ | |
| var hoverString = 'New Messages: ' + unreadmessagecount + | |
| '\nMod Queue: ' + modqueuecount + | |
| '\nUnmoderated Queue: ' + unmoderatedcount + | |
| '\nNew Mod Mail: ' + modmailcount; | |
| $(modbarhid).attr('title', hoverString); | |
| $.log(hoverString); | |
| $.log(TBUtils.configCache); | |
| $.log(TBUtils.mySubs); | |
| }); | |
| $('body').delegate('#tb-toggle-console, #tb-debug-hide', 'click', function () { | |
| if (!consoleShowing) { | |
| $console.show(); | |
| } else { | |
| $console.hide(); | |
| } | |
| consoleShowing = !consoleShowing; | |
| }); | |
| $.log($(modbarhid)); | |
| $.log($('bodzzzz')); | |
| // Settings menu | |
| function showSettings() { | |
| $.log('showing settings') | |
| // I probably should have stored "checked" instead of "on" will have to change that later. | |
| var modnotificationschecked, | |
| messagenotificationschecked, | |
| consolidatedmessageschecked, | |
| unmoderatedonchecked; | |
| if (modnotifications == 'on') { | |
| modnotificationschecked = 'checked'; | |
| } | |
| if (messagenotifications == 'on') { | |
| messagenotificationschecked = 'checked'; | |
| } | |
| if (unmoderatedon) { | |
| unmoderatedonchecked = 'checked'; | |
| } | |
| if(consolidatedmessages) { | |
| consolidatedmessageschecked = 'checked'; | |
| } | |
| // The window in which all settings will be showed. | |
| var html = '\ | |
| <div class="tb-page-overlay tb-settings">\ | |
| <div class="tb-window-wrapper">\ | |
| <div class="tb-window-header"> Toolbox configuration <span class="tb-window-header-options"><a class="tb-help" href="javascript:;" currentpage="">?</a> - <a class="tb-close" href="javascript:;">X</a></span></div>\ | |
| <div class="tb-window-tabs"></div>\ | |
| <div class="tb-window-content">\ | |
| </div>\ | |
| <div class="tb-window-footer" comment="for the looks"><input class="tb-save" type="button" value="save"></div>\ | |
| </div>\ | |
| </div>\ | |
| '; | |
| $(html).appendTo('body').show(); | |
| $('body').css('overflow', 'hidden'); | |
| // Settings for the tool bar. | |
| var htmltoolbar = '\ | |
| <div class="tb-window-content-toolbar">\ | |
| <p>\ | |
| <label><input type="checkbox" name="consolidatedmessages" ' + consolidatedmessageschecked + '> Do show consolidated notifications (x new messages) instead of individual notifications.</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" name="messagenotifications" ' + messagenotificationschecked + '> Get notifications for new messages</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" name="modnotifications" ' + modnotificationschecked + '> Get modqueue notifications</label>\ | |
| </p>\ | |
| <p>\ | |
| Multireddit of subs you want displayed in the modqueue counter:<br>\ | |
| <input type="text" name="modsubreddits">\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" name="unmoderatedon" ' + unmoderatedonchecked + '>Show counter for unmoderated.</label>\ | |
| </p>\ | |
| <p>\ | |
| Multireddit of subs you want displayed in the unmoderated counter:<br>\ | |
| <input type="text" name="unmoderatedsubreddits">\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="debugMode" ' + ((debugMode) ? "checked" : "") + '> Enable debug mode</label>\ | |
| </p>\ | |
| <div class="tb-help-content">Edit toolbar stuff</div>\ | |
| </div>\ | |
| '; | |
| $(htmltoolbar).appendTo('.tb-window-content'); | |
| $('<a href="javascript:;" class="tb-window-content-toolbar">Toolbar Settings</a>').appendTo('.tb-window-tabs'); | |
| $('.tb-help').attr('currentpage', 'tb-window-content-toolbar'); | |
| $("input[name=modsubreddits]").val(unescape(modsubreddits)); | |
| $("input[name=unmoderatedsubreddits]").val(unescape(unmoderatedsubreddits)); | |
| // Edit shortcuts | |
| //console.log(htmlshorcuts); | |
| var htmlshorcuts = '\ | |
| <div class="tb-window-content-shortcuts">\ | |
| <table class="tb-window-content-shortcuts-table"><tr><td>name</td><td> url </td><td class="tb-window-content-shortcuts-td-remove"> remove</td></tr>\ | |
| </table>\ | |
| <a class="tb-add-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + iconadd + '" /></a>\ | |
| <div class="tb-help-content">Add or remove shortcuts here!</div>\ | |
| </div>\ | |
| '; | |
| $(htmlshorcuts).appendTo('.tb-window-content').hide(); | |
| if($.isEmptyObject(shortcuts2)) { | |
| $('<tr class="tb-window-content-shortcuts-tr"><td><input type="text" name="name"> </td><td> <input type="text" name="url"> <td><td class="tb-window-content-shortcuts-td-remove"> \ | |
| <a class="tb-remove-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + iconclose + '" /></a></td></tr>\ | |
| ').appendTo('.tb-window-content-shortcuts-table'); | |
| } else { | |
| $.each(shortcuts2, function(index, value) { | |
| shortcutinput = '<tr class="tb-window-content-shortcuts-tr"><td><input type="text" value="'+ unescape(index) + '" name="name"> </td><td> <input type="text" value="' + unescape(value) + '" name="url"> <td><td class="tb-window-content-shortcuts-td-remove">\ | |
| <a class="tb-remove-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + iconclose + '" /></a></td></tr>\ | |
| <br><br>'; | |
| //console.log(shortcutinput); | |
| $(shortcutinput).appendTo('.tb-window-content-shortcuts-table'); | |
| }); | |
| } | |
| $('<a href="javascript:;" class="tb-window-content-shortcuts">Shortcuts</a>').appendTo('.tb-window-tabs'); | |
| // Settings to toggle the modules | |
| var htmlmodules = '\ | |
| <div class="tb-window-content-modules">\ | |
| <p>\ | |
| <label><input type="checkbox" id="mmpEnabled" ' + ((mmpEnabled) ? "checked" : "") + '> Enable Mod Mail Pro</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="mbEnabled" ' + ((mbEnabled) ? "checked" : "") + '> Enable Mod Button</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="mteEnabled" ' + ((mteEnabled) ? "checked" : "") + '> Enable Mod Tools Enhanced</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="notesEnabled" ' + ((notesEnabled) ? "checked" : "") + '> Enable User Notes</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="dtagEnabled" ' + ((dtagEnabled) ? "checked" : "") + '> Enable Domain Tagger</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="configEnabled" ' + ((configEnabled) ? "checked" : "") + '> Enable Toolbox Config</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="stattitEnabled" ' + ((stattitEnabled) ? "checked" : "") + '> Enable Stattit Tab</label>\ | |
| </p>\ | |
| <div class="tb-help-content">Here you can disable the several toolbox modules.</div>\ | |
| </div>\ | |
| '; | |
| $(htmlmodules).appendTo('.tb-window-content').hide(); | |
| $('<a href="javascript:;" class="tb-window-content-modules">Toggle Modules</a>').appendTo('.tb-window-tabs'); | |
| // Settings to toggle the modules | |
| var htmlmodtools = '\ | |
| <div class="tb-window-content-modtools">\ | |
| <p>\ | |
| <label><input type="checkbox" id="hideactioneditems" ' + ((hideactioneditems) ? "checked" : "") + '> Hide items after mod action</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="ignoreonapprove" ' + ((ignoreonapprove) ? "checked" : "") + '> Ignore reports on approved items</label>\ | |
| <p>\ | |
| <label><input type="checkbox" id="removalreasons" ' + ((removalreasons) ? "checked" : "") + '> Enable removal reasons</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="commentreasons" ' + ((commentreasons) ? "checked" : "") + '> Enable removal reasons for comments</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="rtscomment" ' + ((rtscomment) ? "checked" : "") + '> Post user summery when submitting to /r/reportthespammes</label>\ | |
| </p>\ | |
| <p>\ | |
| <label><input type="checkbox" id="sortmodsubs" ' + ((sortmodsubs) ? "checked" : "") + '> Sort subreddits in /r/mod sidebar accoriding to mod queue count (warning: slows page loading if you mod more than a few subs)</label>\ | |
| </p>\ | |
| <div class="tb-help-content">Settings for Mod Tools Enhanced.</div>\ | |
| </div>\ | |
| '; | |
| if (mteEnabled) { | |
| $(htmlmodtools).appendTo('.tb-window-content').hide(); | |
| $('<a href="javascript:;" class="tb-window-content-modtools">Mod Tools</a>').appendTo('.tb-window-tabs'); | |
| } | |
| // About page | |
| var htmlabout = '\ | |
| <div class="tb-window-content-about">\ | |
| <h3>About:</h3> <a href="http://www.reddit.com/r/toolbox" target="_blank">/r/toolbox</a> <br> made and maintained by: <a href="http://www.reddit.com/user/creesch/">/u/creesch</a> and <a href="http://www.reddit.com/user/agentlame">/u/agentlame</a><br><br>\ | |
| <h3>Special thanks to:</h3>\ | |
| <a href="http://www.reddit.com/user/LowSociety">/u/LowSociety</a> - Stattit tab and several code contributions <br><br>\ | |
| <h3>Credits:</h3>\ | |
| <a href="http://www.famfamfam.com/lab/icons/silk/" target="_blank">Silk icon set by Mark James</a><br>\ | |
| <a href="http://www.reddit.com/user/DEADB33F">Modtools base code by DEADB33F</a>\ | |
| <div class="tb-help-content">This is a about page!</div>\ | |
| </div>'; | |
| $(htmlabout).appendTo('.tb-window-content').hide(); | |
| $('<a href="javascript:;" class="tb-window-content-about">About</a>').appendTo('.tb-window-tabs'); | |
| // $("input[name=shortcuts]").val(unescape(shortcuts)); | |
| } | |
| // Open the settings | |
| $('body').delegate('.tb-toolbarsettings', 'click', function () { | |
| showSettings(); | |
| }); | |
| // change tabs | |
| $('body').delegate('.tb-window-tabs a', 'click', function () { | |
| var tab = $(this).attr('class'); | |
| $('.tb-help').attr('currentpage', tab); | |
| $('.tb-window-content').children().hide(); | |
| $('div.' + tab).show(); | |
| }); | |
| // remove a shortcut | |
| $('body').delegate('.tb-remove-shortcuts', 'click', function () { | |
| $(this).closest('.tb-window-content-shortcuts-tr').remove(); | |
| }); | |
| // add a shortcut | |
| $('body').delegate('.tb-add-shortcuts', 'click', function () { | |
| $('<tr class="tb-window-content-shortcuts-tr"><td><input type="text" name="name"> </td><td> <input type="text" name="url"> <td><td class="tb-window-content-shortcuts-td-remove"> \ | |
| <a class="tb-remove-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + iconclose + '" /></a></td></tr>\ | |
| ').appendTo('.tb-window-content-shortcuts-table'); | |
| }); | |
| // Save the settings | |
| $('body').delegate('.tb-save', 'click', function () { | |
| var messagenotificationssave = $("input[name=messagenotifications]").is(':checked'); | |
| if (messagenotificationssave === true) { | |
| localStorage['Toolbox.Notifier.messagenotifications'] = 'on'; | |
| } else { | |
| localStorage['Toolbox.Notifier.messagenotifications'] = 'off'; | |
| } | |
| var modnotificationscheckedsave = $("input[name=modnotifications]").is(':checked'); | |
| if (modnotificationscheckedsave === true) { | |
| localStorage['Toolbox.Notifier.modnotifications'] = 'on'; | |
| } else { | |
| localStorage['Toolbox.Notifier.modnotifications'] = 'off'; | |
| } | |
| unmoderatedoncheckedsave = $("input[name=unmoderatedon]").is(':checked'); | |
| TBUtils.setting('Notifier', 'unmoderatedon', '', unmoderatedoncheckedsave); | |
| consolidatedmessagescheckedsave = $("input[name=consolidatedmessages]").is(':checked'); | |
| TBUtils.setting('Notifier', 'consolidatedmessages', '', consolidatedmessagescheckedsave); | |
| shortcuts = escape($("input[name=shortcuts]").val()); | |
| localStorage['Toolbox.Notifier.shortcuts'] = shortcuts; | |
| modsubreddits = $("input[name=modsubreddits]").val(); | |
| localStorage['Toolbox.Notifier.modsubreddits'] = modsubreddits; | |
| unmoderatedsubreddits = $("input[name=unmoderatedsubreddits]").val(); | |
| localStorage['Toolbox.Notifier.unmoderatedsubreddits'] = unmoderatedsubreddits; | |
| TBUtils.setting('Utils', 'debugMode', '', $("#debugMode").prop('checked')); | |
| // Save shortcuts | |
| if ($('.tb-window-content-shortcuts-tr').length = 0) { | |
| localStorage['Toolbox.Notifier.shortcuts2'] = JSON.stringify('{}'); | |
| } else { | |
| shortcuts2 = JSON.parse('{}'); | |
| $('.tb-window-content-shortcuts-tr').each(function () { | |
| name = $(this).find('input[name=name]').val(); | |
| url = $(this).find('input[name=url]').val(); | |
| if (name.trim() !== '' || url.trim() !== '') { | |
| shortcuts2[escape(name)] = escape(url); | |
| } | |
| }); | |
| localStorage['Toolbox.Notifier.shortcuts2'] = JSON.stringify(shortcuts2); | |
| } | |
| // Save which modules are enabled. | |
| TBUtils.setting('ModMailPro', 'enabled', '', $("#mmpEnabled").prop('checked')); | |
| TBUtils.setting('ModButton', 'enabled', '', $("#mbEnabled").prop('checked')); | |
| TBUtils.setting('ModTools', 'enabled', '', $("#mteEnabled").prop('checked')); | |
| TBUtils.setting('UserNotes', 'enabled', '', $("#notesEnabled").prop('checked')); | |
| TBUtils.setting('DomainTagger', 'enabled', '', $("#dtagEnabled").prop('checked')); | |
| TBUtils.setting('TBConfig', 'enabled', '', $("#configEnabled").prop('checked')); | |
| TBUtils.setting('StattitTab', 'enabled', '', $("#stattitEnabled").prop('checked')); | |
| // Save MTE settings. | |
| TBUtils.setting('ModTools', 'hideactioneditems', '', $("#hideactioneditems").prop('checked')); | |
| TBUtils.setting('ModTools', 'ignoreonapprove', '', $("#ignoreonapprove").prop('checked')); | |
| TBUtils.setting('ModTools', 'removalreasons', '', $("#removalreasons").prop('checked')); | |
| TBUtils.setting('ModTools', 'commentreasons', '', $("#commentreasons").prop('checked')); | |
| TBUtils.setting('ModTools', 'rtscomment', '', $("#rtscomment").prop('checked')); | |
| TBUtils.setting('ModTools', 'sortmodsubs', '', $("#sortmodsubs").prop('checked')); | |
| $('.tb-settings').remove(); | |
| $('body').css('overflow', 'auto'); | |
| window.location.reload(); | |
| }); | |
| $('body').delegate('.tb-help', 'click', function () { | |
| var tab = $(this).attr('currentpage'); | |
| tab = '.' + tab; | |
| var helpwindow = window.open('', '', 'width=500,height=600,location=0,menubar=0,top=100,left=100'); | |
| var htmlcontent = $(tab).find('.tb-help-content').html(); | |
| var html = '\ | |
| <!DOCTYPE html>\ | |
| <html>\ | |
| <head>\ | |
| <style>\ | |
| body {\ | |
| font: normal x-small verdana,arial,helvetica,sans-serif;\ | |
| }\ | |
| </style>\ | |
| </head>\ | |
| <body>\ | |
| <div class="help-content">' + htmlcontent + '</div>\ | |
| </body>\ | |
| </html>\ | |
| '; | |
| helpwindow.document.write(html); | |
| helpwindow.focus(); | |
| }); | |
| // Close the Settings menu | |
| $('body').delegate('.tb-close', 'click', function () { | |
| $('.tb-settings').remove(); | |
| $('body').css('overflow', 'auto'); | |
| }); | |
| // | |
| // Counters and notifications | |
| // | |
| function getmessages() { | |
| $.log('getMessage'); | |
| // get some of the variables again, since we need to determine if there are new messages to display and counters to update. | |
| var lastchecked = TBUtils.setting('Notifier', 'lastchecked', -1), | |
| author = '', | |
| body_html = '', | |
| now = new Date().getTime(); | |
| // Update counters. | |
| unreadmessagecount = TBUtils.setting('Notifier', 'unreadmessagecount', 0); | |
| modqueuecount = TBUtils.setting('Notifier', 'modqueuecount', 0); | |
| unmoderatedcount = TBUtils.setting('Notifier', 'unmoderatedcount', 0); | |
| modmailcount = TBUtils.setting('Notifier', 'modmailcount', 0); | |
| // | |
| // Update methods | |
| // | |
| function updateMessagesCount(count) { | |
| if (count < 1) { | |
| $('#mailCount').html(''); | |
| $('#mail').attr('class', 'nohavemail'); | |
| $('#mail').attr('title', 'no new mail!'); | |
| $('#tb-mail').attr('class', 'nohavemail'); | |
| $('#tb-mail').attr('title', 'no new mail!'); | |
| $('#tb-mail').attr('href', 'http://www.reddit.com/message/inbox/'); | |
| $('#tb-mailCount').attr('href', 'http://www.reddit.com/message/inbox/'); | |
| } else { | |
| $('#mail').attr('class', 'havemail'); | |
| $('#mail').attr('title', 'new mail!'); | |
| $('#tb-mail').attr('class', 'havemail'); | |
| $('#tb-mail').attr('title', 'new mail!'); | |
| $('#tb-mail').attr('href', 'http://www.reddit.com/message/unread'); | |
| $('#tb-mailCount').attr('href', 'http://www.reddit.com/message/unread'); | |
| } | |
| $('#tb-mailCount').html('[' + count + ']'); | |
| if (count > 0) { | |
| $('#mailCount').html('[' + count + ']'); | |
| } | |
| } | |
| function updateModqueueCount(count) { | |
| $('#tb-queueCount').html('[' + count + ']'); | |
| } | |
| function updateUnmodCount(count) { | |
| $('#tb-unmoderatedcount').html('[' + count + ']'); | |
| } | |
| function updateModMailCount(count) { | |
| if (count < 1) { | |
| $('#tb-modmail').attr('class', 'nohavemail'); | |
| $('#tb-modmail').attr('title', 'no new mail!'); | |
| //$('#tb-modmail').attr('href', 'http://www.reddit.com/message/moderator/'); | |
| } else { | |
| $('#modmail').attr('class', 'havemail'); | |
| $('#modmail').attr('title', 'new mail!'); | |
| //$('#modmail').attr('href', 'http://www.reddit.com/message/moderator/unread'); | |
| $('#tb-modmail').attr('class', 'havemail'); | |
| $('#tb-modmail').attr('title', 'new mail!'); | |
| //$('#tb-modmail').attr('href', 'http://www.reddit.com/message/moderator/unread'); | |
| } | |
| $('#tb-modmailcount').html('[' + count + ']'); | |
| $('#tb-modmail').attr('href', 'http://www.reddit.com/message/moderator/'); | |
| } | |
| if ((now - lastchecked) < checkInterval) { | |
| updateMessagesCount(unreadmessagecount); | |
| updateModqueueCount(modqueuecount); | |
| updateUnmodCount(unmoderatedcount); | |
| updateModMailCount(modmailcount); | |
| return; | |
| } | |
| // We're checking now. | |
| TBUtils.setting('Notifier', 'lastchecked', '', now); | |
| // | |
| // Messages | |
| // | |
| // The reddit api is silly sometimes, we want the title or reported comments and there is no easy way to get it, so here it goes: | |
| // a silly function to get the title anyway. The $.getJSON is wrapped in a function to prevent if from running async outside the loop. | |
| function getcommentitle(unreadcontexturl, unreadcontext, unreadauthor, unreadbody_html) { | |
| $.getJSON(unreadcontexturl, function (jsondata) { | |
| var commenttitle = jsondata[0].data.children[0].data.title; | |
| TBUtils.notification('New reply:' + commenttitle + ' from:' + unreadauthor, $(unreadbody_html).text().substring(0, 400) + | |
| '...', 'http://www.reddit.com' + unreadcontext); | |
| }); | |
| } | |
| // getting unread messages | |
| $.getJSON('http://www.reddit.com/message/unread.json', function (json) { | |
| var count = json.data.children.length || 0; | |
| TBUtils.setting('Notifier', 'unreadmessagecount', '', count); | |
| updateMessagesCount(count); | |
| if (count === 0) return; | |
| // Are we allowed to show a popup? | |
| if (messagenotifications == 'on') { | |
| if (count > unreadmessagecount) { | |
| if (consolidatedmessages) { | |
| var messageamount = count - unreadmessagecount; | |
| var notifcationbody; | |
| if (messageamount == 1) { | |
| notifcationbody = 'There is one new message in your inbox' | |
| } else { | |
| notifcationbody = 'There are ' + messageamount.toString(2) + ' new messages in your inbox' | |
| } | |
| TBUtils.notification('New messages', notifcationbody, 'http://www.reddit.com/message/unread'); | |
| } else { | |
| // set up an array in which we will load the last 100 messages that have been displayed. | |
| // this is done through a array since the modqueue is in chronological order of post date, so there is no real way to see what item got send to queue first. | |
| var pushedunread = JSON.parse(localStorage['Toolbox.Notifier.unreadpushed'] || '[]'); | |
| for (var i = 0; i < count; i++) { | |
| if ($.inArray(json.data.children[i].data.name, pushedunread) == -1 && json.data.children[i].kind == 't1') { | |
| var context = json.data.children[i].data.context; | |
| body_html = TBUtils.htmlDecode(json.data.children[i].data.body_html); | |
| author = json.data.children[i].data.author; | |
| var contexturl = 'http://www.reddit.com' + context.slice(0, -10) + '.json'; | |
| getcommentitle(contexturl, context, author, body_html); | |
| pushedunread.push(json.data.children[i].data.name); | |
| // if it is a personal message, or some other unknown idea(future proof!) we use this code block | |
| } else if ($.inArray(json.data.children[i].data.name, pushedunread) == -1) { | |
| author = json.data.children[i].data.author; | |
| body_html = TBUtils.htmlDecode(json.data.children[i].data.body_html); | |
| //var subject = htmlDecode(json.data.children[i].data.subject); | |
| var id = json.data.children[i].data.id; | |
| TBUtils.notification('New message from:' + author, $(body_html).text().substring(0, 400) + '...', 'http://www.reddit.com/message/messages/' + id); | |
| pushedunread.push(json.data.children[i].data.name); | |
| } | |
| } | |
| if (pushedunread.length > 100) { | |
| pushedunread.splice(0, 100 - pushedunread.length); | |
| } | |
| TBUtils.setting('Notifier', 'unreadpushed', '', pushedunread); | |
| } | |
| } | |
| } | |
| }); | |
| // | |
| // Modqueue | |
| // | |
| // wrapper around $.getJSON so it can be part of a loop | |
| function procesmqcomments(mqlinkid, mqreportauthor, mqidname) { | |
| $.getJSON(mqlinkid, function (jsondata) { | |
| var infopermalink = jsondata.data.children[0].data.permalink, | |
| infotitle = jsondata.data.children[0].data.title, | |
| infosubreddit = jsondata.data.children[0].data.subreddit; | |
| infopermalink = infopermalink + mqidname.substring(3); | |
| TBUtils.notification('Modqueue - /r/' + infosubreddit + ' - comment:', mqreportauthor + '\'s comment in ' + infotitle, 'http://www.reddit.com' + infopermalink + '?context=3'); | |
| }); | |
| } | |
| // getting modqueue | |
| $.getJSON('http://www.reddit.com/r/' + modsubreddits + '/about/modqueue.json?limit=100', function (json) { | |
| var count = json.data.children.length || 0; | |
| updateModqueueCount(count); | |
| TBUtils.setting('Notifier', 'modqueuecount', '', count); | |
| if (count === 0) return; | |
| if (modnotifications == 'on') { | |
| // Ok let's have a look and see if there are actually new items to display | |
| if (count > modqueuecount) { | |
| if (consolidatedmessages) { | |
| var modqueamount = count - modqueuecount; | |
| //console.log(count); | |
| //console.log(modqueuecount); | |
| var notifcationbody; | |
| if (modqueamount == 1) { | |
| notifcationbody = 'There is one new item in modqueue' | |
| } else { | |
| notifcationbody = 'There are ' + modqueamount.toString(2) + ' new items in modqueue' | |
| } | |
| TBUtils.notification('New modqueue items', notifcationbody , 'http://www.reddit.com/r/' + modsubreddits + '/about/modqueue'); | |
| } else { | |
| // set up an array in which we will load the last 100 items that have been displayed. | |
| // this is done through a array since the modqueue is in chronological order of post date, so there is no real way to see what item got send to queue first. | |
| var pusheditems = JSON.parse(localStorage['Toolbox.Notifier.modqueuepushed'] || '[]'); | |
| for (var i = 0; i < count; i++) { | |
| if ($.inArray(json.data.children[i].data.name, pusheditems) == -1 && json.data.children[i].kind == 't3') { | |
| var mqpermalink = item.data.permalink, | |
| mqtitle = item.data.title, | |
| mqauthor = item.data.author, | |
| mqsubreddit = item.data.subreddit; | |
| TBUtils.notification('Modqueue: /r/' + mqsubreddit + ' - post', mqtitle + ' By: ' + mqauthor, 'http://www.reddit.com' + mqpermalink); | |
| pusheditems.push(item.data.name); | |
| } else if ($.inArray(item.data.name, pusheditems) == -1) { | |
| var reportauthor = item.data.author, | |
| idname = item.data.name, | |
| linkid = 'http://www.reddit.com/api/info.json?id=' + item.data.link_id; | |
| //since we want to add some adition details to this we call the previous declared function | |
| procesmqcomments(linkid, reportauthor, idname); | |
| pusheditems.push(item.data.name); | |
| } | |
| } | |
| if (pusheditems.length > 100) { | |
| pusheditems.splice(0, 100 - pusheditems.length); | |
| } | |
| TBUtils.setting('Notifier', 'modqueuepushed', '', pusheditems); | |
| } | |
| } | |
| } | |
| }); | |
| // | |
| // Unmoderated | |
| // | |
| // getting unmoderated, for now only a counter, otherwise it might be to much with the notifications | |
| if (unmoderatedon) { | |
| $.getJSON('http://www.reddit.com/r/' + unmoderatedsubreddits + '/about/unmoderated.json?limit=100', function (json) { | |
| var count = json.data.children.length || 0; | |
| TBUtils.setting('Notifier', 'unmoderatedcount', '', count); | |
| updateUnmodCount(count); | |
| }); | |
| } | |
| // | |
| // Modmail | |
| // | |
| // getting unread modmail, will not show replies because... well the api sucks in that regard. | |
| $.getJSON('http://www.reddit.com/message/moderator/unread.json', function (json) { | |
| var count = json.data.children.length || 0; | |
| if (count > modmailcount) { | |
| if (consolidatedmessages) { | |
| var modmailamount = count - modmailcount; | |
| var notifcationbody; | |
| if (modmailamount == 1) { | |
| notifcationbody = 'There is one new message in modmail.' | |
| } else { | |
| notifcationbody = 'There are ' + modmailamount.toString(2) + ' new messages in modmail' | |
| } | |
| TBUtils.notification('New modmail messages', notifcationbody, 'http://www.reddit.com/message/moderator/'); | |
| } else { | |
| for (var i = 0; i < count; i++) { | |
| var pushedmodmail = TBUtils.setting('Notifier', 'modmailpushed', '[]'); | |
| if (TBUtils.setting('ModMailPro', 'hideinvitespam', false) && (json.data.children[i].data.subject == 'moderator invited' || json.data.children[i].data.subject == 'moderator added')) { | |
| invitespamid = json.data.children[i].data.name; | |
| $.post('/api/read_message', { | |
| id: invitespamid, | |
| uh: reddit.modhash, | |
| api_type: 'json' | |
| }); | |
| } else { | |
| if ($.inArray(json.data.children[i].data.name, pushedmodmail) == -1) { | |
| var modmailbody = json.data.children[i].data.body; | |
| modmailsubject = json.data.children[i].data.subject; | |
| modmailsubreddit = json.data.children[i].data.subreddit; | |
| modmailpermalink = json.data.children[i].data.id; | |
| TBUtils.notification('Modmail: /r/' + modmailsubreddit + ' : ' + modmailsubject, modmailbody, 'http://www.reddit.com/message/messages/' + modmailpermalink); | |
| } | |
| } | |
| if (pushedmodmail.length > 100) { | |
| pushedmodmail.splice(0, 100 - pushedmodmail.length); | |
| } | |
| TBUtils.setting('Notifier', 'modmailpushed', '', pushedmodmail); | |
| } | |
| } | |
| } | |
| TBUtils.setting('Notifier', 'modmailcount', '', count); | |
| updateModMailCount(count); | |
| }); | |
| } | |
| // How often we check for new messages, this will later be adjustable in the settings. | |
| setInterval(getmessages, checkInterval); | |
| getmessages(); | |
| } | |
| // Add script to page | |
| (function () { | |
| // Check if we are running as an extension | |
| if (typeof self.on !== "undefined" || (typeof chrome !== "undefined" && chrome.extension)) { | |
| init(); | |
| return; | |
| } | |
| // Check if TBUtils has been added. | |
| if (!window.TBUadded) { | |
| window.TBUadded = true; | |
| var utilsURL = 'http://agentlame.github.io/toolbox/tbutils.js'; | |
| var cssURL = 'http://agentlame.github.io/toolbox/tb.css'; | |
| $('head').prepend('<script type="text/javascript" src=' + utilsURL + '></script>'); | |
| $('head').prepend('<link rel="stylesheet" type="text/css" href="' + cssURL + '"></link>'); | |
| } | |
| // Do not add script to page until TBUtils is added. | |
| (function loadLoop() { | |
| setTimeout(function () { | |
| if (typeof TBUtils !== "undefined") { | |
| init(); | |
| } else { | |
| loadLoop(); | |
| } | |
| }, 100); | |
| })(); | |
| function init() { | |
| var s = document.createElement('script'); | |
| s.textContent = "(" + tbnoti.toString() + ')();'; | |
| document.head.appendChild(s); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment