From 180ca13661e17581ac031b89140eda006a4b2a0e Mon Sep 17 00:00:00 2001 From: Smokey <9442271+smokey019@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:13:56 -0700 Subject: [PATCH] Smokey's Utilities 1.2.0 * Fixed: Mod keybinds should properly detect if you're using the chat input now. The keybinds will only fire if you are not typing in the chat input window. * Changed: Auto go to Live Following Directory uses a route detection for more reliability now. This will also only force going over to the Live tab once in case you want to go to Overview tab to look at videos etc... --- src/smokemotes/index.jsx | 32 ++++++++++++++++++++------------ src/smokemotes/manifest.json | 6 +++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/smokemotes/index.jsx b/src/smokemotes/index.jsx index 1440f6e8..1b0ba8ea 100644 --- a/src/smokemotes/index.jsx +++ b/src/smokemotes/index.jsx @@ -14,6 +14,7 @@ class SmokeysUtils extends Addon { this.inject('site'); this.injectAs('site_chat', 'site.chat'); this.inject('site.fine'); + this.inject('site.router'); this.user = this.site.getUser(); this.onKeyDown = this.onKeyDown.bind(this); @@ -22,6 +23,16 @@ class SmokeysUtils extends Addon { message_id: undefined, }; + this.firstLoad = 0; + + this.site.router.on(':route', (route, match) => { + if (match && match[0] == '/directory/following' && this.firstLoad === 0){ + this.liveFollowing(); + // do this just in case the user wants to go to Overview later for videos etc.. + this.firstLoad = 1; + } + }); + this.settings.add('smokemotes.pinned_mentions', { default: true, @@ -215,9 +226,9 @@ class SmokeysUtils extends Addon { onEnable() { this.log.debug("Smokey's Utilities module was enabled successfully."); - this.keep_hd_video(); - - this.liveFollowing(); + window.addEventListener('load', () => { + this.keep_hd_video(); + }); this.mod_keybind_handler(); @@ -270,7 +281,8 @@ class SmokeysUtils extends Addon { pinned_log = createElement('div', { id: 'smokey_pinned_log', - class: 'pinned-highlight-log tw-absolute tw-top-0 tw-full-width tw-z-above tw-c-background-base' + class: 'pinned-highlight-log tw-absolute tw-top-0 tw-full-width tw-z-above tw-c-background-base', + style: 'z-order:11 !important;' }); el.parentNode.prepend(pinned_log); @@ -389,7 +401,7 @@ class SmokeysUtils extends Addon { try { document.addEventListener( 'visibilitychange', - (e) => { + e => { e.stopImmediatePropagation(); }, true, @@ -402,10 +414,7 @@ class SmokeysUtils extends Addon { } liveFollowing() { - if ( - window.location.href == 'https://www.twitch.tv/directory/following' && - this.chat.context.get('smokemotes.auto_live_follow_page') - ) { + if (this.chat.context.get('smokemotes.auto_live_follow_page')) { try { document.querySelector('a[data-a-target="following-live-tab"]').click(); } catch (error) { @@ -434,8 +443,7 @@ class SmokeysUtils extends Addon { onKeyDown(e) { if ( - document.activeElement.matches('input') || - document.activeElement.matches('textarea') || + document.activeElement == document.querySelector('div[data-a-target="chat-input"]') || e.ctrlKey || e.metaKey || e.shiftKey || @@ -448,7 +456,7 @@ class SmokeysUtils extends Addon { const keyCode = e.keyCode || e.which; switch (keyCode) { - // timeout + // timeout case 84: this.resolve('site.chat').ChatService.first.sendMessage( diff --git a/src/smokemotes/manifest.json b/src/smokemotes/manifest.json index ee8e1e26..d9457526 100644 --- a/src/smokemotes/manifest.json +++ b/src/smokemotes/manifest.json @@ -1,8 +1,8 @@ { "enabled": true, "requires": [], - "icon": "https://i.imgur.com/WVFY4R5.png", - "version": "1.1.7", + "icon": "https://i.imgur.com/a98FccA.png", + "version": "1.2.0", "short_name": "smokeys_utils", "name": "Smokey's Utilities", "author": "Smokey", @@ -10,5 +10,5 @@ "website": "https://smokey.gg/", "settings": "add_ons.smokemotes", "created": "2019-12-08T01:03:54.000Z", - "updated": "2023-01-21T15:24:50.357Z" + "updated": "2023-04-28T21:44:47.582Z" } \ No newline at end of file