-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMoarEmotes.user.js
More file actions
67 lines (59 loc) · 2.52 KB
/
MoarEmotes.user.js
File metadata and controls
67 lines (59 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ==UserScript==
// @name MoarEmotes
// @namespace http://tampermonkey.net/
// @version 2025-04-29
// @description Extended Emote List for Pikidiary
// @author zav
// @match https://pikidiary.lol/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pikidiary.lol
// @grant none
// ==/UserScript==
(function() {
'use strict';
fetch('https://gist.githubusercontent.com/JustAGoodUsername/d0cfebb32023bec097b3e471a041905b/raw/fd54e0d07b69a8f5d4f7b8f33149d26f276c4344/emotes.json')
.then(response => {
if (!response.ok) {
throw new Error(`Oops: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log("Fetched Data:", data);
console.log("Found images:");
const startIndex = (Array.isArray(data) && data.length > 0 && Array.isArray(data[0]) && data[0].includes('original')) ? 1 : 0;
for (let i = startIndex; i < data.length; i++) {
const imageUrl = Array.isArray(data[i]) ? data[i][0] : data[i];
loadEmotes(imageUrl);
}
console.log(`\nFound ${data.length - startIndex} images.`);
return data;
})
.catch(error => {
console.error("Oops:", error);
return [];
});
// REGARDING THIS FUNCTION:
// I HATE THE SPLIT FUNCTION IN JAVASCRIPT. IT SUCKS. AND DID NOT WANT TO WORK.
// I HAVE RECENTLY FOUND THAT IT WAS A PARSING ERROR REGARDING MY FETCHING METHODS. I'M A LITTLE REMEDIAL RIGHT NOW. BE NICE.
function loadEmotes(link) {
console.log("called with:", link, typeof link);
const emotesContainer = document.querySelector(".dropdown-cont");
const image = document.createElement("img");
let filenameWithoutExtension = "";
const match = link.match(/\/([^/]+)\.(png|gif|jpeg)$/); // Regex to capture only digits before .gif/.png/.etc
if (match && match[1]) {
filenameWithoutExtension = match[1];
} else {
console.warn(`Could not extract filename using regex: ${link}.`);
}
image.src = link;
image.alt = "Emote";
image.style.cursor = "pointer";
image.style.marginRight = "5px";
image.onclick = function() {
if (!window.__cfRLUnblockHandlers) return false; // idk why jax does this but its okay
insertEmote(`:${filenameWithoutExtension}:`);
};
emotesContainer.appendChild(image);
}
})();