Skip to content

Commit 38a53d4

Browse files
authored
Emote Picker & 7TV Personal Emotes
1. 7TV Personal Emotes that are not approved for personal use should no longer appear in auto completion 2. Added 7TV Personal Emotes to the emote picker 3. First tab in emote picker has been changed from Twitch to Sub
2 parents ad3f68f + 81a8211 commit 38a53d4

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

pages/channel.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</div>
4141

4242
<div id="emote_picker_sections_selector">
43-
<button id="twitch_emotes">Twitch</button>
43+
<button id="sub_emotes">Sub</button>
4444
<button id="channel_emotes">Channel</button>
4545
<button id="global_emotes">Global</button>
4646
</div>
@@ -260,7 +260,7 @@ <h2>Stream Chat</h2>
260260
<script src="src/tooltip.js"></script>
261261
<script src="src/channel/userCard.js"></script>
262262
<script src="src/channel/contextMenu.js"></script>
263-
<script src="src/channel/emote_picker.js"></script>
263+
<script src="src/channel/emotePicker.js"></script>
264264
</body>
265265

266266
</html>

src/channel/SevenTVHelperV2.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async function pushCosmeticUserUsingGQL(cosmetic_id) {
9999
"Content-Type": "application/json"
100100
},
101101
body: JSON.stringify({
102-
"query": "query GetUserForUserPage($id: ObjectID!) { user(id: $id) { id username display_name avatar_url emote_sets { id flags capacity emotes { id name data { name host { files { name height width } } owner { username display_name } } } } style { color paint { id kind name function color angle shape image_url repeat stops { at color } shadows { x_offset y_offset radius color } } badge { id kind name tooltip tag } } connections { id platform } } }",
102+
"query": "query GetUserForUserPage($id: ObjectID!) { user(id: $id) { id username display_name avatar_url emote_sets { id flags capacity emotes { id name data { name state host { files { name height width } } owner { username display_name } } } } style { color paint { id kind name function color angle shape image_url repeat stops { at color } shadows { x_offset y_offset radius color } } badge { id kind name tooltip tag } } connections { id platform } } }",
103103
"variables": {
104104
"id": `${cosmetic_id}`
105105
}
@@ -115,8 +115,8 @@ async function pushCosmeticUserUsingGQL(cosmetic_id) {
115115
if (data && data["data"]) {
116116
data = data["data"];
117117
}
118-
119-
if (!data || !data["user"] || data["user"].length < 1) { return; };
118+
119+
if (!Object?.keys(data?.["user"])?.length) { return; };
120120

121121
let user_id = null;
122122
const userData = data["user"];
@@ -164,6 +164,8 @@ async function pushCosmeticUserUsingGQL(cosmetic_id) {
164164
infoTable["personal_set_id"].push(set["id"]);
165165

166166
if (set["emotes"] && set["emotes"].length > 0) {
167+
set["emotes"] = set["emotes"].filter(item => item.data.state.includes("PERSONAL"));
168+
167169
const emotes = await mapPersonalEmotes(set["emotes"]);
168170
infoTable["personal_emotes"].push(...emotes);
169171
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const emote_picker_sections = emote_picker.querySelector("#emote_picker_sections
66
const searchInput = emote_picker_search.querySelector("#emote_picker_search_input");
77
const emote_picker_sections_selector = emote_picker.querySelector("#emote_picker_sections_selector");
88

9-
let section = "twitch_emotes";
9+
let section = "sub_emotes";
1010

1111
let modes = {
1212
match_case: false,
@@ -59,7 +59,7 @@ function groupEmotesByOwner(emotes) {
5959
return { mappedSections, remaining };
6060
}
6161

62-
function displayEmotes(emote_picker_section = "twitch_emotes") {
62+
function displayEmotes(emote_picker_section = "sub_emotes") {
6363
let emoteSections = [];
6464

6565
if (emote_picker.style.display !== "flex") {
@@ -77,7 +77,7 @@ function displayEmotes(emote_picker_section = "twitch_emotes") {
7777
emote_picker_sections.innerHTML = "";
7878
section = emote_picker_section;
7979

80-
if (emote_picker_section == "twitch_emotes" || emote_picker_section == "search_emotes") {
80+
if (emote_picker_section == "sub_emotes" || emote_picker_section == "search_emotes") {
8181
const sub_emotes = removeEmoteDuplicates(
8282
[
8383
...TTVEmoteData.filter(emote => emote.emote_type === "subscriptions" && typeof emote.name === "string"),
@@ -154,6 +154,8 @@ function displayEmotes(emote_picker_section = "twitch_emotes") {
154154
...broadcaster_bits_emotes
155155
];
156156

157+
const foundTTVUser = TTVUsersData.find(user => user.name == `@${tmiUsername}`);
158+
157159
emoteSections.push(
158160
...broadcaster_emotes,
159161
...mapped_sub_emotes,
@@ -164,6 +166,12 @@ function displayEmotes(emote_picker_section = "twitch_emotes") {
164166
{ name: "Hype Train", emotes: hypetrain_emotes },
165167
{ name: "Limited Time", emotes: limited_emotes }
166168
);
169+
170+
if (foundTTVUser?.cosmetics?.personal_emotes) {
171+
emoteSections.push(
172+
{ name: "7TV Personal Emotes", emotes: foundTTVUser.cosmetics.personal_emotes }
173+
);
174+
}
167175
}
168176

169177
if (emote_picker_section == "channel_emotes" || emote_picker_section == "search_emotes") {
@@ -208,7 +216,7 @@ function displayEmotes(emote_picker_section = "twitch_emotes") {
208216
if (!searchInput.value.length) {
209217
emote_picker_sections_selector.style.display = "flex";
210218

211-
displayEmotes("twitch_emotes");
219+
displayEmotes("sub_emotes");
212220

213221
return;
214222
} else {

0 commit comments

Comments
 (0)