Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove new reddit platform handling #1028

Merged
merged 5 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ All Toolbox subreddit settings and data are stored in subreddit wikis through ve
[amo]: https://addons.mozilla.org/en-US/firefox/addon/reddit-moderator-toolbox/
[edge-store]: https://microsoftedge.microsoft.com/addons/detail/moderator-toolbox-for-red/nolhfmoadpbgfeonfnjlcfmhhkmdlfcl
[discord]: https://discord.gg/8fGCykQ
[post-on-reddit]: https://new.reddit.com/r/toolbox/submit?text=true
[post-on-reddit]: https://www.reddit.com/r/toolbox/submit?text=true
[user-docs]: https://www.reddit.com/r/toolbox/w/docs
[nodejs]: https://nodejs.org/
[contributing]: /CONTRIBUTING.md
Expand Down
28 changes: 17 additions & 11 deletions extension/data/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,19 @@ async function doSettingsUpdates () {
await TBStorage.setSettingAsync('QueueTools', 'reportsThreshold', 0);
}

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

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

// (old) modmail pro removed in v7, RIP old modmail. nuke its settings
await Promise.all([
// (old) modmail pro removed in v7, RIP old modmail
...[
'inboxStyle',
'filteredSubs',
'defaultCollapse',
Expand All @@ -263,8 +264,13 @@ async function doSettingsUpdates () {
'entryProcessRate',
'chunkProcessSize',
'twoPhaseProcessing',
].map(setting => TBStorage.setSettingAsync('ModMail', setting, undefined)));
}
].map(setting => TBStorage.setSettingAsync('ModMail', setting, undefined)),

// new reddit is dead, long live shreddit i guess. the setting to
// skip the new reddit lightbox when viewing comments no longer
// applies to anything, remove it
TBStorage.setSettingAsync('Comments', 'commentsAsFullPage', undefined),
]);

// End: version changes.

Expand Down
21 changes: 0 additions & 21 deletions extension/data/modules/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ import TBListener from '../tblistener.js';
import {Module} from '../tbmodule.jsx';
import * as TBStorage from '../tbstorage.js';
import * as TBui from '../tbui.js';
import {currentPlatform, RedditPlatform} from '../util/platform.ts';
import {modbarExists} from './modbar.js';

const self = new Module({
name: 'Comments',
id: 'Comments',
enabledByDefault: true,
settings: [
{
id: 'commentsAsFullPage',
type: 'boolean',
default: false,
advanced: false,
description: 'Always open comments as new page (instead of lightbox).',
},
{
id: 'openContextInPopup',
type: 'boolean',
Expand Down Expand Up @@ -277,7 +269,6 @@ self.initOldReddit = async function ({hideRemoved, approveComments, spamRemoved,
};

function init ({
commentsAsFullPage,
openContextInPopup,
hideRemoved,
approveComments,
Expand All @@ -290,18 +281,6 @@ function init ({
if (TBCore.isOldReddit) {
self.initOldReddit({hideRemoved, approveComments, spamRemoved, hamSpammed});
}
// Do not open lightbox but go to full comment page.
if (commentsAsFullPage && currentPlatform === RedditPlatform.NEW) {
$body.on('click', 'a', function (event) {
const subredditCommentsPageReg = /^\/r\/([^/]*?)\/comments\/([^/]*?)\/([^/]*?)\/?$/;
const $this = $(this);
const thisHref = $this.attr('href');
if (subredditCommentsPageReg.test(thisHref)) {
event.preventDefault();
window.location.href = thisHref;
}
});
}

if (highlighted.length) {
TBListener.on('comment', async e => {
Expand Down
29 changes: 0 additions & 29 deletions extension/data/modules/macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as TBHelpers from '../tbhelpers.js';
import {Module} from '../tbmodule.jsx';
import * as TBStorage from '../tbstorage.js';
import * as TBui from '../tbui.js';
import {currentPlatform, RedditPlatform} from '../util/platform.ts';

export default new Module({
name: 'Mod Macros',
Expand Down Expand Up @@ -204,34 +203,6 @@ export default new Module({
});
}

if (currentPlatform === RedditPlatform.NEW) {
$('body').on('click', 'button:contains("Reply")', async function () {
const $this = $(this);
const $comment = $this.closest('.Comment');
const commentDetails = $comment.find('.tb-frontend-container[data-tb-type="comment"]').data('tb-details');
const subreddit = commentDetails.data.subreddit.name;
const thingID = commentDetails.data.id;

const isMod = await TBCore.isModSub(subreddit);
if (isMod) {
getConfig(subreddit, (success, config) => {
// if we're a mod, add macros to top level reply button.
if (success && config.length > 0) {
const $macro = $(`
<select class="tb-macro-select tb-action-button" data-subreddit="${subreddit}" data-thingID="${thingID}">
<option value=${MACROS}>macros</option>
</select>
`).appendTo($comment);
$comment.on('click', 'button[type="reset"], button[type="submit"]', () => {
$macro.remove();
});
populateSelect('.tb-macro-select', subreddit, config, 'comment');
}
});
}
});
}

window.addEventListener('TBNewPage', async event => {
if (event.detail.pageType === 'subredditCommentsPage') {
const subreddit = event.detail.pageDetails.subreddit;
Expand Down
3 changes: 1 addition & 2 deletions extension/data/modules/queue_overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ export default new Module({

if (
(currentPlatform === RedditPlatform.OLD && overlayFromBarOld)
// TODO: should the overlayFromBarRedesign setting also apply to shreddit?
|| (currentPlatform === RedditPlatform.NEW && overlayFromBarRedesign)
|| (currentPlatform === RedditPlatform.SHREDDIT && overlayFromBarRedesign)
) {
$body.on('click', '#tb-modqueue, #tb-queueCount', event => {
if (event.ctrlKey || event.metaKey) {
Expand Down
2 changes: 1 addition & 1 deletion extension/data/tbcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function getLastVersion () {
* modmail we use www.reddit.com; wnywhere else we use whatever is the current
* domain.
*/
export const baseDomain = window.location.hostname === 'mod.reddit.com' || window.location.hostname === 'new.reddit.com'
export const baseDomain = window.location.hostname === 'mod.reddit.com'
? 'https://www.reddit.com'
: `https://${window.location.hostname}`;

Expand Down
18 changes: 4 additions & 14 deletions extension/data/util/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
export enum RedditPlatform {
/** "old Reddit," old.reddit.com */
OLD,
// new.reddit.com, the first "new reddit", has been completely removed from
// the site and is no longer accessible. it previously used `NEW`
/**
* "new reddit," often referred to as new.reddit.com, though this frontend
* is increasingly being replaced by shreddit even on the new.reddit domain
*/
NEW,
/**
* "shreddit" or "new new reddit," sh.reddit.com and gradually replacing
* "new reddit" on new.reddit.com
* "shreddit" or "new new reddit" (or nowadays just "new reddit" to many,
* since the first "new reddit" is completely dead), sh.reddit.com
*/
SHREDDIT,
/**
Expand All @@ -29,9 +26,6 @@ export const currentPlatform = (() => {
if (document.getElementById('header')) {
return RedditPlatform.OLD;
}
if (document.getElementById('AppRouter-main-content')) {
return RedditPlatform.NEW;
}
if (document.querySelector('shreddit-app')) {
return RedditPlatform.SHREDDIT;
}
Expand All @@ -50,10 +44,6 @@ export function isUserLoggedInQuick () {
case RedditPlatform.OLD:
return document.body.classList.contains('loggedin');

// new Reddit will have text in `#USER_DROPDOWN_ID` (username, karma, etc)
case RedditPlatform.NEW:
return !!document.getElementById('USER_DROPDOWN_ID')?.innerText;

// shreddit will have an attribute `user-logged-in` on its app root
case RedditPlatform.SHREDDIT:
return !!document.querySelector('shreddit-app[user-logged-in=true]');
Expand Down
Loading