Skip to content

Instantly share code, notes, and snippets.

@twnlink
Created March 25, 2022 04:41
Show Gist options
  • Save twnlink/ef4e01ffa003ecac2a2b2c43a7e37342 to your computer and use it in GitHub Desktop.
Save twnlink/ef4e01ffa003ecac2a2b2c43a7e37342 to your computer and use it in GitHub Desktop.
A simple userscript that enables r/place on Reddit early.
// ==UserScript==
// @name Force Enable r/place
// @namespace https://creatable.cafe
// @description Force enable r/place
// @version 1.0.0
// @author creatable
// @license CC0-1.0
// @include https://www.reddit.com/*
// @include https://new.reddit.com/*
// @include https://reddit.com/*
// @run-at document-start
// ==/UserScript==
function getWebpack() {
let found = false;
let patched = false;
// rushed garbage, this is just because we load so fucking early
return new Promise((resolve) => {
let webpackObj;
// I think a Proxy would need the parent to actually intercept this, and you can't replace the window with a proxy so...
Object.defineProperty(window, "__LOADABLE_LOADED_CHUNKS__", {
get() {
return webpackObj;
},
set(val) {
webpackObj = new Proxy(val, {
get(obj, prop) {
return obj[prop];
},
set(obj, prop, val) {
obj[prop] = val;
if (prop == "push" && !patched) {
const webpackPush = val;
obj[prop] = function (...args) {
const ret = webpackPush.apply(this, args);
if (!found && obj.length > 43) {
const modules = {};
const randomId = Math.random().toString();
const randomIdTwo = Math.random().toString();
webpackPush([
[randomId],
{
[randomIdTwo](_, _2, { c }) {
for (const mod in c) {
modules[mod] = c[mod].exports;
}
},
},
[[randomIdTwo]],
]);
obj.pop();
resolve(modules);
found = true;
}
return ret;
};
patched = true;
}
return true;
},
});
},
});
});
}
(async () => {
const originalDefineProperty = Object.defineProperty;
Object.defineProperty = function (...args) {
args[2].configurable = true;
return originalDefineProperty.apply(this, args);
};
const modules = await getWebpack();
Object.defineProperty(
modules["./src/reddit/selectors/experiments/hotPotato.ts"],
"a",
{
value: () => true,
}
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment