Skip to content

Instantly share code, notes, and snippets.

@nightpool
Forked from twilight-sparkle-irl/webcrack.discord.min.js
Last active August 8, 2019 17:53
Show Gist options
  • Save nightpool/8772a70ca71ffb2e3fefee68a037984a to your computer and use it in GitHub Desktop.
Save nightpool/8772a70ca71ffb2e3fefee68a037984a to your computer and use it in GitHub Desktop.
webcrack for tumblr
// With acknowledgments to zoe bootsy.
// Copyright 2019, licensed under the GPL v3.0 or later.
const webcrack3_injection = (_module, _exports, require) => {
window.webcrack3 = {
require,
moduleFunctions: require.m,
findModuleFunctionWithSourceLike (string_or_regex) {
const predicate = typeof string_or_regex === "string" ?
s => s.indexOf(string_or_regex) !== -1 :
string_or_regex.test.bind(string_or_regex);
return Object.entries(this.moduleFunctions).
filter((name, func) => predicate(func.toString()));
},
loadedModules: require.c,
findExportedName (key) {
return Object.values(this.loadedModules).
filter(m => m.exports && m.exports[key]).
map(m => m.exports[key]);
}
}
}
(window.webpackJsonp = window.webpackJsonp || []).push([
[1337], {webcrack3_injection}, [['webcrack3_injection']]
]);
@nightpool
Copy link
Author

nightpool commented Aug 3, 2019

Some examples:

// Find a css class by name
const postCssClass = webcrack3.findExportedName('listTimelineObject');

// Find all SVG icons by their source code
const svgIcons = webcrack3.findModuleFunctionWithSourceLike('http://www.w3.org/2000/svg');

// Enable all of the unreleased features
// this requires React dev tools to be pointing at the root RedpopContainer
const FeatureFlags = webcrack3.findExportedName('FeatureFlags')[0];
Object.values(FeatureFlags).forEach(f => $r.props.features[f] = true)

// Use Tumblr's own API helpers
const apiHelperModule = Object.values(webcrack3.loadedModules).find(m => m.exports && m.exports.ApiRequest).exports;
const apiHelper = apiHelperModule.default($r.props.apiFetch); // react dev tools again.....
apiHelper.getUserInfo().fetch().then(console.log);

@nightpool
Copy link
Author

nightpool commented Aug 4, 2019

Note that after setting $r.props programmatically you have to force the component to re-render, which you can do by calling $r.forceUpdate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment