var pd = { version: '1.4.4', bookmarkver: '1.1', init : function() { pd.checks.versions(); if (window.pd_processing !== true) { if (pd.checks.location()) { $('#pd__central').find('.complete,.processing').hide(); $('#pd__form').show(); pd.setup.basicSettings(); pd.setup.applyDom(); } else { if (confirm('This script is designed to be run from your own user profile. Would you like to navigate there?')) { document.location = 'http://reddit.com/u/me/overview'; } } } }, checks: { versions: function () { function checkBookmarkletVersion() { if (typeof window.bookmarkver === 'undefined' || window.bookmarkver !== pd.bookmarkver) { if (confirm('There\'s been an update to the bookmarklet. Would you like to go to the Github repo in order to get the latest version?')) { document.location.href = 'https://github.com/j0be/PowerDeleteSuite'; return false; } } return true; } function checkAppVersion() { pd.prevRunVersion = localStorage.getItem('pd_ver') ? localStorage.getItem('pd_ver') : '0'; localStorage.setItem('pd_ver',pd.version); if (pd.version !== pd.prevRunVersion) { if (confirm('You\'ve gotten the latest update! You are now running PowerDeleteSuite v'+pd.version+'. Would you like to open the changelog in a new tab?')) { $.ajax({url: '/r/PowerDeleteSuite/new.json'}).then(function(data) { window.open('http://reddit.com'+data.data.children[0].data.permalink); }, function() { window.open('http://reddit.com/r/PowerDeleteSuite'); }); } } return true; } return pd.debugging || (checkBookmarkletVersion() && checkAppVersion()); }, location: function () { return document.location.hostname.split('.').slice(-2).join('.') == 'reddit.com' && document.location.href.match('/user/') && $('.titlebox h1').first().text() === $('#header-bottom-right .user a').first().text(); } }, setup: { basicSettings: function () { pd.config = { uh : $('#config').innerHTML ? $('#config').innerHTML.replace(/.*?modhash.{1}: .{1}/,'').replace(/[^a-z0-9].*/,'') : $('#config')[0].innerHTML.replace(/.*?modhash.{1}: .{1}/,'').replace(/[^a-z0-9].*/,''), user : $('#header-bottom-right .user a').first().text() }; pd.endpoints = { 'comments': '/user/'+pd.config.user+'/comments/.json', 'submissions': '/user/'+pd.config.user+'/submitted/.json', 'search': '/search.json', }; }, applyDom: function () { if (pd.debugging) {$('#pd__central,#pd__style').remove('');} document.title = pd.config.user +' | Power Delete Suite'; $(window).on("error", pd.error); $('.sitetable,.neverEndingReddit').remove(); if ($('#pd__central').length === 0) { $('body>.content[role=\'main\']').append('
'); } if ($('#pd__style').length === 0) { $('head').first().append('