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 showImages onInit #5512

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 0 additions & 23 deletions lib/modules/showImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ import type {
GenericMedia,
} from '../core/host';
import { Host } from '../core/host';
import { loadOptions } from '../core/init';
import { Module } from '../core/module';
import {
positiveModulo,
downcast,
filterMap,
Thing,
PagePhases,
SelectedThing,
addCSS,
batch,
Expand All @@ -38,7 +36,6 @@ import {
frameThrottle,
isPageType,
isAppType,
stopPageContextScript,
string,
waitForEvent,
watchForElements,
Expand All @@ -57,7 +54,6 @@ import {
Permissions,
Storage,
} from '../environment';
import * as Modules from '../core/modules';
import * as Options from '../core/options';
import * as __hosts from './hosts';
import * as Notifications from './notifications';
Expand All @@ -78,7 +74,6 @@ import {
expandos,
activeExpandos,
} from './showImages/expando';
import vreddit from './hosts/vreddit';

const siteModules: Map<string, Host<any, any>> = new Map(
Object.values(__hosts).map(host => [host.moduleID, downcast(host, Host)]), // ensure that all hosts are instances of `Host`
Expand Down Expand Up @@ -457,24 +452,6 @@ module.options = {
}, {}),
};

module.onInit = () => {
if (isAppType('r2')) {
// We'll probably replace Reddit's video player, so disable the script containing it for now
// This happens on `onInit` since RES' options load slower than the script's
const preventVideoPlayerScriptTasks = [
stopPageContextScript(script => (/^\/?videoplayer\./).test(new URL(script.src, location.origin).pathname), 'head', true),
// Reddit loads scripts which initializes the video player, which will cause a slowdown if not blocked
stopPageContextScript(script => !!script.innerHTML.match('RedditVideoPlayer'), PagePhases.contentStart.then(() => document.querySelector('#siteTable')), false),
];

loadOptions.then(() => {
// We might need to restore the native player
const removeNativePlayer = Modules.isRunning(module) && isSiteModuleEnabled(vreddit) && vreddit.options && vreddit.options.forceReplaceNativeExpando.value;
if (!removeNativePlayer) forEachSeq(preventVideoPlayerScriptTasks, ({ undo }) => undo());
});
}
};

module.exclude = [
/^\/ads\/[\-\w\._\?=]*/i,
'submit',
Expand Down