How to use these scripts:
- Open a browser and log into your discord account.
- Open devtools using Ctrl+Shift+I (or Cmd ⌘ + Option ⌥ + I)
- Go to the console tab.
- Paste the snippet and hit enter. You might also need to type "allow pasting" if this is your first time using snippets.
This snippet will export your favourite gifs into a file named discord-favorite-gifs.json.
window.FrecencyUserSettings ??= webpackChunkdiscord_app.push([[Symbol()],,e=>Object.values(e.c).values().map(m=>m.exports).filter(x=>typeof x=="object"&&x!=window&&x!=DOMTokenList.prototype).flatMap(x=>[x,...Object.values(x)]).find(x=>x?.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings"))]);
function downloadJSON(content, download) {
const json = JSON.stringify(content, null, 2);
Object.assign(document.createElement("a"), {
href: URL.createObjectURL(new Blob([json], { type: "application/json" })),
download
}).click();
}
FrecencyUserSettings.loadIfNecessary();
downloadJSON(FrecencyUserSettings.getCurrentValue().favoriteGifs.gifs, "discord-favorite-gifs.json");This snippet will ask you to pick a file with your (previously exported) gifs. It will merge them with the current set of favourite gifs, moving the old ones further down the list.
Note
If you generated your favourites file using a different tool/snippet it could be incompatible. Make sure it follows the specific structure that discord uses.
Click to view example
{
// The object keys store the source urls - this is what gets sent in chat when you select a gif
"https://tenor.com/view/cirno-fumo-touhou-fumo-touhou-gif-23545101": {
// Gif format: NONE = 0, IMAGE = 1, VIDEO = 2
"format": 2,
// The media url - discord uses this to generate thumbnails in the gif picker
"src": "https://media.tenor.co/videos/10b5a62192508ab85ec795ce4124f12a/mp4",
// The thumbnail width
"width": 640,
// The thumbnail height
"height": 358,
// Numerical ordering index - gets incremented with each newly favorited gif.
// This snippet automatically updates the indices of new gifs to always be higher than old gifs,
// which does not affect their relative order.
"order": 78
},
// ...
}window.FrecencyUserSettings ??= webpackChunkdiscord_app.push([[Symbol()],,e=>Object.values(e.c).values().map(m=>m.exports).filter(x=>typeof x=="object"&&x!=window&&x!=DOMTokenList.prototype).flatMap(x=>[x,...Object.values(x)]).find(x=>x?.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings"))]);
window._log = (msg, color) => console.log(`%c${msg}`, `font-size:2rem;color:${color}`);
function uploadJSON() {
return new Promise((res, rej) =>
Object.assign(document.createElement("input"), {
type: "file",
accept: "application/json",
onchange: ({ target: { files: [file] } }) => file?.text().then(JSON.parse).then(res).catch(rej)
}).click()
);
}
uploadJSON()
.catch(() => _log("Failed to parse JSON.", "red"))
.then(gifs =>
FrecencyUserSettings.updateAsync("favoriteGifs", state => {
const offset = Object.values(state.gifs).map(g => g.order).reduce((a, b) => Math.max(a, b), 0) + 1;
Object.values(gifs).sort((a, b) => a.order - b.order).forEach((gif, i) => gif.order = offset + i);
Object.assign(state.gifs, gifs);
const valid = state[Symbol.for("protobuf-ts/message-type")].toBinary(state).length <= 762880;
if (!valid) _log("Too many gifs.", "red");
return valid;
}, 0)
)
.catch(() => _log("Unspecified/Network error.", "red"))
.then(() => _log("Successfully imported gifs.", "green"));Caution
This action is irreversible. Backup your gifs before using this snippet.
Click to view snippet
window.FrecencyUserSettings ??= webpackChunkdiscord_app.push([[Symbol()],,e=>Object.values(e.c).values().map(m=>m.exports).filter(x=>typeof x=="object"&&x!=window&&x!=DOMTokenList.prototype).flatMap(x=>[x,...Object.values(x)]).find(x=>x?.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings"))]);
FrecencyUserSettings.updateAsync("favoriteGifs", state => void delete state.gifs);
how do i use this