diff --git a/src/main.js b/src/main.js index cc2c182f..83a6c8d0 100644 --- a/src/main.js +++ b/src/main.js @@ -149,7 +149,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}` FrankerFaceZ.Logger = Logger; const VER = FrankerFaceZ.version_info = { - major: 4, minor: 0, revision: 0, extra: '-rc13.18', + major: 4, minor: 0, revision: 0, extra: '-rc13.19', commit: __git_commit__, build: __webpack_hash__, toString: () => diff --git a/src/modules/chat/emote_info.gql b/src/modules/chat/emote_info.gql new file mode 100644 index 00000000..c3788d5d --- /dev/null +++ b/src/modules/chat/emote_info.gql @@ -0,0 +1,25 @@ +query FFZ_GetEmoteInfo($id: ID!) { + emote(id: $id) { + id + setID + text + subscriptionProduct { + id + displayName + state + owner { + id + login + displayName + } + tier + url + self { + benefit { + id + endsAt + } + } + } + } +} \ No newline at end of file diff --git a/src/modules/chat/emotes.js b/src/modules/chat/emotes.js index 28c3eb7c..b0e45b16 100644 --- a/src/modules/chat/emotes.js +++ b/src/modules/chat/emotes.js @@ -6,9 +6,11 @@ import Module from 'utilities/module'; import {ManagedStyle} from 'utilities/dom'; -import {has, timeout, SourcedSet} from 'utilities/object'; +import {get, has, timeout, SourcedSet} from 'utilities/object'; import {CLIENT_ID, NEW_API, API_SERVER, IS_OSX} from 'utilities/constants'; +import GET_EMOTE from './emote_info.gql'; + const MOD_KEY = IS_OSX ? 'metaKey' : 'ctrlKey'; const EXTRA_INVENTORY = [33563]; @@ -201,15 +203,45 @@ export default class Emotes extends Module { if ( ! ds ) return; - const provider = ds.provider; + const provider = ds.provider, + click_emote = this.parent.context.get('chat.click-emotes'), + click_sub = this.parent.context.get('chat.sub-emotes'); - if ( event.shiftKey && this.parent.context.get('chat.click-emotes') ) { + if ( event.shiftKey && (click_emote || click_sub) ) { let url; - if ( provider === 'twitch' ) + if ( provider === 'twitch' ) { url = `https://twitchemotes.com/emotes/${ds.id}`; - else if ( provider === 'ffz' ) { + if ( click_sub ) { + const apollo = this.resolve('site.apollo'); + if ( apollo ) { + apollo.client.query({ + query: GET_EMOTE, + variables: { + id: ds.id + } + }).then(result => { + const prod = get('data.emote.subscriptionProduct', result); + if ( prod && prod.state === 'ACTIVE' && prod.owner && prod.owner.login ) + url = `https://www.twitch.tv/subs/${prod.owner.login}`; + else if ( ! click_emote ) + return false; + + if ( url ) { + const win = window.open(); + if ( win ) { + win.opener = null; + win.location = url; + } + } + }); + + return true; + } + } + + } else if ( provider === 'ffz' ) { const emote_set = this.emote_sets[ds.set], emote = emote_set && emote_set.emotes[ds.id]; @@ -223,6 +255,9 @@ export default class Emotes extends Module { url = `https://www.frankerfacez.com/emoticons/${emote.id}`; } + if ( ! click_emote ) + return false; + if ( url ) { const win = window.open(); if ( win ) { diff --git a/src/modules/chat/index.js b/src/modules/chat/index.js index 0916beac..2cc688bd 100644 --- a/src/modules/chat/index.js +++ b/src/modules/chat/index.js @@ -550,6 +550,15 @@ export default class Chat extends Module { } }); + this.settings.add('chat.click-emotes.sub-pages', { + default: true, + ui: { + path: 'Chat > Behavior >> General', + title: 'Open Twitch subscription pages by Shift-Clicking emotes when relevant.', + component: 'setting-check-box' + } + }); + const ts = new Date(0).toLocaleTimeString().toUpperCase(), default_24 = ts.lastIndexOf('PM') === -1 && ts.lastIndexOf('AM') === -1; diff --git a/src/sites/twitch-twilight/modules/css_tweaks/index.js b/src/sites/twitch-twilight/modules/css_tweaks/index.js index 7b4ecf06..8b71b19f 100644 --- a/src/sites/twitch-twilight/modules/css_tweaks/index.js +++ b/src/sites/twitch-twilight/modules/css_tweaks/index.js @@ -25,7 +25,7 @@ const CLASSES = { 'player-ext-hover': '.player:not([data-controls="true"]) .extension-container', 'player-event-bar': '.channel-root .live-event-banner-ui__header', - 'player-rerun-bar': '.channel-root div.tw-c-text-overlay:not([data-a-target="hosting-ui-header"])', + 'player-rerun-bar': '.channel-root__player_container div.tw-c-text-overlay:not([data-a-target="hosting-ui-header"])', 'pinned-cheer': '.pinned-cheer,.pinned-cheer-v2', 'whispers': '.whispers', diff --git a/src/sites/twitch-twilight/modules/css_tweaks/styles/emote-menu.scss b/src/sites/twitch-twilight/modules/css_tweaks/styles/emote-menu.scss index 50b7c5d8..65769404 100644 --- a/src/sites/twitch-twilight/modules/css_tweaks/styles/emote-menu.scss +++ b/src/sites/twitch-twilight/modules/css_tweaks/styles/emote-menu.scss @@ -1,8 +1,8 @@ .tw-button-icon[data-a-target="emote-picker-button"] { .tw-button-icon__icon { - padding: .7rem .1rem .1rem .3rem; + padding: .6rem .4rem .2rem .4rem; - figure { + div > div { &:before { display: inline-block; width: 2.4rem;