From 77d90a7232f59bbf7d0fac02eeea2ca69506bb45 Mon Sep 17 00:00:00 2001 From: Sandeep S Date: Tue, 28 Nov 2023 19:29:23 +0530 Subject: [PATCH] fixed typo #pd_style in line 140 powerdeletesuite --- bookmarklet.js | 54 ++- powerdeletesuite.js | 949 +++++++++++++++++++++++++++++--------------- 2 files changed, 654 insertions(+), 349 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index 4e23723..99c56f4 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,22 +1,34 @@ -javascript: (function() { - window.bookmarkver = '1.4'; - var isReddit = document.location.hostname.split('.').slice(-2).join('.') === 'reddit.com'; - var isOverview = document.location.href.match(/\/overview\b/); - if (isReddit && isOverview) { - var cachBustUrl = 'https://raw.githubusercontent.com/j0be/PowerDeleteSuite/master/powerdeletesuite.js?' + (new Date().getDate()); - fetch(cachBustUrl).then(function(response) { - return response.text(); - }).then(function(data) { - var script = document.createElement('script'); - script.id = 'pd-script'; - script.innerHTML = data; - document.getElementsByTagName('head')[0].appendChild(script); - }).catch(function() { - alert('Error retreiving PowerDeleteSuite from github'); - }); - } 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'; - } else { - alert('Please go to your reddit profile before running this script'); - } +javascript: (function () { + window.bookmarkver = "1.4"; + var isReddit = + document.location.hostname.split(".").slice(-2).join(".") === "reddit.com"; + var isOverview = document.location.href.match(/\/overview\b/); + if (isReddit && isOverview) { + var cachBustUrl = `?${new Date().getDate()}`; + // var cachBustUrl = 'https://raw.githubusercontent.com/j0be/PowerDeleteSuite/master/powerdeletesuite.js?' + (new Date().getDate()); + var cachBustUrl = + "hhttps://raw.githubusercontent.com/saandman/PowerDeleteSuite/master/powerdeletesuite.js?" + + new Date().getDate(); + fetch(cachBustUrl) + .then(function (response) { + return response.text(); + }) + .then(function (data) { + var script = document.createElement("script"); + script.id = "pd-script"; + script.innerHTML = data; + document.getElementsByTagName("head")[0].appendChild(script); + }) + .catch(function () { + alert("Error retreiving PowerDeleteSuite from github"); + }); + } 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"; + } else { + alert("Please go to your reddit profile before running this script"); + } })(); diff --git a/powerdeletesuite.js b/powerdeletesuite.js index 207b2e6..be05a73 100644 --- a/powerdeletesuite.js +++ b/powerdeletesuite.js @@ -1,17 +1,21 @@ var pd = { - version: '1.4.8', - bookmarkver: '1.4', - init : function() { + 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__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'; + 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"; } } } @@ -19,25 +23,47 @@ var pd = { 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'; + 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); + 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'); - }); + 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; @@ -45,87 +71,129 @@ var pd = { 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(); - } + 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() + 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', + 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'; + 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('
'); + $(".sitetable,.neverEndingReddit").remove(); + if ($("#pd__central").length === 0) { + $("body>.content[role='main']").append("
"); } - if ($('#pd__style').length === 0) { - $('head').first().append('