Skip to content

Commit a4b2e43

Browse files
authored
remove new reddit platform handling (#1028)
1 parent 53c2943 commit a4b2e43

File tree

7 files changed

+24
-79
lines changed

7 files changed

+24
-79
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ All Toolbox subreddit settings and data are stored in subreddit wikis through ve
2525
[amo]: https://addons.mozilla.org/en-US/firefox/addon/reddit-moderator-toolbox/
2626
[edge-store]: https://microsoftedge.microsoft.com/addons/detail/moderator-toolbox-for-red/nolhfmoadpbgfeonfnjlcfmhhkmdlfcl
2727
[discord]: https://discord.gg/8fGCykQ
28-
[post-on-reddit]: https://new.reddit.com/r/toolbox/submit?text=true
28+
[post-on-reddit]: https://www.reddit.com/r/toolbox/submit?text=true
2929
[user-docs]: https://www.reddit.com/r/toolbox/w/docs
3030
[nodejs]: https://nodejs.org/
3131
[contributing]: /CONTRIBUTING.md

extension/data/init.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,19 @@ async function doSettingsUpdates () {
229229
await TBStorage.setSettingAsync('QueueTools', 'reportsThreshold', 0);
230230
}
231231

232-
// Some new modmail settings were removed in 5.7.0
233-
if (lastVersion < 50700) {
234-
await TBStorage.setSettingAsync('NewModMail', 'searchhelp', undefined);
235-
await TBStorage.setSettingAsync('NewModMail', 'checkForNewMessages', undefined);
236-
}
232+
// Clean up removed settings - it doesn't really matter what version
233+
// we're coming from, we just want to make sure these removed settings
234+
// aren't cluttering up storage
235+
await Promise.all([
236+
// Some new modmail settings were removed in 5.7.0
237+
TBStorage.setSettingAsync('NewModMail', 'searchhelp', undefined),
238+
TBStorage.setSettingAsync('NewModMail', 'checkForNewMessages', undefined),
237239

238-
if (lastVersion < 70000) {
239240
// Beta mode setting removed in favor of dedicated beta builds #917
240-
await TBStorage.setSettingAsync(SETTINGS_NAME, 'betaMode', undefined);
241+
TBStorage.setSettingAsync(SETTINGS_NAME, 'betaMode', undefined),
241242

242-
// (old) modmail pro removed in v7, RIP old modmail. nuke its settings
243-
await Promise.all([
243+
// (old) modmail pro removed in v7, RIP old modmail
244+
...[
244245
'inboxStyle',
245246
'filteredSubs',
246247
'defaultCollapse',
@@ -263,8 +264,13 @@ async function doSettingsUpdates () {
263264
'entryProcessRate',
264265
'chunkProcessSize',
265266
'twoPhaseProcessing',
266-
].map(setting => TBStorage.setSettingAsync('ModMail', setting, undefined)));
267-
}
267+
].map(setting => TBStorage.setSettingAsync('ModMail', setting, undefined)),
268+
269+
// new reddit is dead, long live shreddit i guess. the setting to
270+
// skip the new reddit lightbox when viewing comments no longer
271+
// applies to anything, remove it
272+
TBStorage.setSettingAsync('Comments', 'commentsAsFullPage', undefined),
273+
]);
268274

269275
// End: version changes.
270276

extension/data/modules/comment.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ import TBListener from '../tblistener.js';
77
import {Module} from '../tbmodule.jsx';
88
import * as TBStorage from '../tbstorage.js';
99
import * as TBui from '../tbui.js';
10-
import {currentPlatform, RedditPlatform} from '../util/platform.ts';
1110
import {modbarExists} from './modbar.js';
1211

1312
const self = new Module({
1413
name: 'Comments',
1514
id: 'Comments',
1615
enabledByDefault: true,
1716
settings: [
18-
{
19-
id: 'commentsAsFullPage',
20-
type: 'boolean',
21-
default: false,
22-
advanced: false,
23-
description: 'Always open comments as new page (instead of lightbox).',
24-
},
2517
{
2618
id: 'openContextInPopup',
2719
type: 'boolean',
@@ -277,7 +269,6 @@ self.initOldReddit = async function ({hideRemoved, approveComments, spamRemoved,
277269
};
278270

279271
function init ({
280-
commentsAsFullPage,
281272
openContextInPopup,
282273
hideRemoved,
283274
approveComments,
@@ -290,18 +281,6 @@ function init ({
290281
if (TBCore.isOldReddit) {
291282
self.initOldReddit({hideRemoved, approveComments, spamRemoved, hamSpammed});
292283
}
293-
// Do not open lightbox but go to full comment page.
294-
if (commentsAsFullPage && currentPlatform === RedditPlatform.NEW) {
295-
$body.on('click', 'a', function (event) {
296-
const subredditCommentsPageReg = /^\/r\/([^/]*?)\/comments\/([^/]*?)\/([^/]*?)\/?$/;
297-
const $this = $(this);
298-
const thisHref = $this.attr('href');
299-
if (subredditCommentsPageReg.test(thisHref)) {
300-
event.preventDefault();
301-
window.location.href = thisHref;
302-
}
303-
});
304-
}
305284

306285
if (highlighted.length) {
307286
TBListener.on('comment', async e => {

extension/data/modules/macros.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as TBHelpers from '../tbhelpers.js';
66
import {Module} from '../tbmodule.jsx';
77
import * as TBStorage from '../tbstorage.js';
88
import * as TBui from '../tbui.js';
9-
import {currentPlatform, RedditPlatform} from '../util/platform.ts';
109

1110
export default new Module({
1211
name: 'Mod Macros',
@@ -204,34 +203,6 @@ export default new Module({
204203
});
205204
}
206205

207-
if (currentPlatform === RedditPlatform.NEW) {
208-
$('body').on('click', 'button:contains("Reply")', async function () {
209-
const $this = $(this);
210-
const $comment = $this.closest('.Comment');
211-
const commentDetails = $comment.find('.tb-frontend-container[data-tb-type="comment"]').data('tb-details');
212-
const subreddit = commentDetails.data.subreddit.name;
213-
const thingID = commentDetails.data.id;
214-
215-
const isMod = await TBCore.isModSub(subreddit);
216-
if (isMod) {
217-
getConfig(subreddit, (success, config) => {
218-
// if we're a mod, add macros to top level reply button.
219-
if (success && config.length > 0) {
220-
const $macro = $(`
221-
<select class="tb-macro-select tb-action-button" data-subreddit="${subreddit}" data-thingID="${thingID}">
222-
<option value=${MACROS}>macros</option>
223-
</select>
224-
`).appendTo($comment);
225-
$comment.on('click', 'button[type="reset"], button[type="submit"]', () => {
226-
$macro.remove();
227-
});
228-
populateSelect('.tb-macro-select', subreddit, config, 'comment');
229-
}
230-
});
231-
}
232-
});
233-
}
234-
235206
window.addEventListener('TBNewPage', async event => {
236207
if (event.detail.pageType === 'subredditCommentsPage') {
237208
const subreddit = event.detail.pageDetails.subreddit;

extension/data/modules/queue_overlay.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ export default new Module({
272272

273273
if (
274274
(currentPlatform === RedditPlatform.OLD && overlayFromBarOld)
275-
// TODO: should the overlayFromBarRedesign setting also apply to shreddit?
276-
|| (currentPlatform === RedditPlatform.NEW && overlayFromBarRedesign)
275+
|| (currentPlatform === RedditPlatform.SHREDDIT && overlayFromBarRedesign)
277276
) {
278277
$body.on('click', '#tb-modqueue, #tb-queueCount', event => {
279278
if (event.ctrlKey || event.metaKey) {

extension/data/tbcore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export function getLastVersion () {
255255
* modmail we use www.reddit.com; wnywhere else we use whatever is the current
256256
* domain.
257257
*/
258-
export const baseDomain = window.location.hostname === 'mod.reddit.com' || window.location.hostname === 'new.reddit.com'
258+
export const baseDomain = window.location.hostname === 'mod.reddit.com'
259259
? 'https://www.reddit.com'
260260
: `https://${window.location.hostname}`;
261261

extension/data/util/platform.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
export enum RedditPlatform {
55
/** "old Reddit," old.reddit.com */
66
OLD,
7+
// new.reddit.com, the first "new reddit", has been completely removed from
8+
// the site and is no longer accessible. it previously used `NEW`
79
/**
8-
* "new reddit," often referred to as new.reddit.com, though this frontend
9-
* is increasingly being replaced by shreddit even on the new.reddit domain
10-
*/
11-
NEW,
12-
/**
13-
* "shreddit" or "new new reddit," sh.reddit.com and gradually replacing
14-
* "new reddit" on new.reddit.com
10+
* "shreddit" or "new new reddit" (or nowadays just "new reddit" to many,
11+
* since the first "new reddit" is completely dead), sh.reddit.com
1512
*/
1613
SHREDDIT,
1714
/**
@@ -29,9 +26,6 @@ export const currentPlatform = (() => {
2926
if (document.getElementById('header')) {
3027
return RedditPlatform.OLD;
3128
}
32-
if (document.getElementById('AppRouter-main-content')) {
33-
return RedditPlatform.NEW;
34-
}
3529
if (document.querySelector('shreddit-app')) {
3630
return RedditPlatform.SHREDDIT;
3731
}
@@ -50,10 +44,6 @@ export function isUserLoggedInQuick () {
5044
case RedditPlatform.OLD:
5145
return document.body.classList.contains('loggedin');
5246

53-
// new Reddit will have text in `#USER_DROPDOWN_ID` (username, karma, etc)
54-
case RedditPlatform.NEW:
55-
return !!document.getElementById('USER_DROPDOWN_ID')?.innerText;
56-
5747
// shreddit will have an attribute `user-logged-in` on its app root
5848
case RedditPlatform.SHREDDIT:
5949
return !!document.querySelector('shreddit-app[user-logged-in=true]');

0 commit comments

Comments
 (0)