var pd = { version: "1.4.8", bookmarkver: "1.4", 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 can only be run from your own user profile on reddit. Would you like to go there now?" ) ) { document.location = "https://old.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?" ) ) { alert( 'Sadly, there]\'s no way to automatically update the bookmark. :/\nScroll down to the "Install PowerDeleteSuite" button on the github page. Replace your CURRENT bookmark with the one found there to install the latest bookmark.' ); 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( "https://reddit.com" + data.data.children[0].data.permalink ); }, function () { window.open("https://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/") && document.location.href.match("/overview") && $(".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("