From f181cc97249a03680a10cf301a232d9d6dcfe687 Mon Sep 17 00:00:00 2001 From: Ronald Troyer Date: Mon, 30 Dec 2019 16:40:00 -0500 Subject: [PATCH] Removing any jquery dependency from the bookmark. --- bookmarklet.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bookmarklet.js b/bookmarklet.js index 5e52184..a523042 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1 +1,22 @@ -javascript:(function() {window.bookmarkver = '1.3'; if (document.location.hostname.split('.').slice(-2).join('.') == 'reddit.com' && typeof $ !== 'undefined') {$.ajax({url: 'https://raw.githubusercontent.com/j0be/PowerDeleteSuite/master/powerdeletesuite.js?'+(new Date().getDate())}).then(function(data) {var str = ''; if ($('#pd-script').length === 0) {$('head').append(str); } else {$('#pd-script').replaceWith(str); } }, function() {alert('Error retreiving PowerDeleteSuite from github'); }); } else {if(confirm('This script is designed to be run from your user profile on reddit. Would you like to go there now?')) {document.location = 'http://old.reddit.com/u/me/overview'; } } })(); +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 = 'http://old.reddit.com/u/me/overview'; + } else { + alert('Please go to your reddit profile before running this script'); + } +})();