From 460f14707bca99c8b37d3633e4ea7d9a41756ffa Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 8 Jul 2023 17:44:42 -0700 Subject: [PATCH 1/9] initial commit --- src/scripts/tweaks.json | 5 ++ src/scripts/tweaks/subtle_activity_mutuals.js | 57 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/scripts/tweaks/subtle_activity_mutuals.js diff --git a/src/scripts/tweaks.json b/src/scripts/tweaks.json index 71dcf54c9..2e2501a5f 100644 --- a/src/scripts/tweaks.json +++ b/src/scripts/tweaks.json @@ -58,6 +58,11 @@ "default": false, "inherit": "tweaks.preferences.subtle_follow" }, + "subtle_activity_mutuals": { + "type": "checkbox", + "label": "Make following/mutuals indicators on notifications more subtle", + "default": false + }, "hide_footer_tooltips": { "type": "checkbox", "label": "Hide control button tooltips in the post footer", diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js new file mode 100644 index 000000000..8da93763d --- /dev/null +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -0,0 +1,57 @@ +import { pageModifications } from '../../util/mutations.js'; +import { keyToCss } from '../../util/css_map.js'; +import { buildStyle } from '../../util/interface.js'; +import { dom } from '../../util/dom.js'; + +const spanClass = 'xkit-tweaks-subtle-activity-span'; + +const styleElement = buildStyle(` +${keyToCss('generalLabelContainer')} > .${spanClass} { + display: inline-block; + overflow-x: clip; + width: calc(100% - 16px); +} + +a:not(:hover) ${keyToCss('generalLabelContainer')} > svg { + margin-left: 0; +} + +a:not(:hover) ${keyToCss('generalLabelContainer')} > .${spanClass} { + width: 0; +} +`); + +const transitionStyleElement = buildStyle(` +${keyToCss('generalLabelContainer')} > svg, .${spanClass} { + transition: width 0.5s ease, margin 0.5s ease; +} +`); + +const processLabels = labels => labels.forEach(label => { + const textNode = label.firstChild; + if (textNode.nodeName !== '#text') return; + + const span = dom('span', { class: spanClass }, null, [textNode.textContent]); + label.replaceChild(span, textNode); +}); + +const waitForRender = () => + new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))); + +export const main = async function () { + pageModifications.register(keyToCss('generalLabelContainer'), processLabels); + + document.documentElement.append(styleElement); + waitForRender().then(() => document.documentElement.append(transitionStyleElement)); +}; + +export const clean = async function () { + pageModifications.unregister(processLabels); + styleElement.remove(); + transitionStyleElement.remove(); + + [...document.querySelectorAll(`.${spanClass}`)].forEach(span => { + const textNode = document.createTextNode(span.textContent); + span.parentNode.replaceChild(textNode, span); + }); +}; From d7945ce6a1ce1e7d18e13aca95e02fe1146589e3 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 8 Jul 2023 18:49:31 -0700 Subject: [PATCH 2/9] hardcode expanded span width --- src/scripts/tweaks/subtle_activity_mutuals.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index 8da93763d..40aee24c3 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -9,7 +9,6 @@ const styleElement = buildStyle(` ${keyToCss('generalLabelContainer')} > .${spanClass} { display: inline-block; overflow-x: clip; - width: calc(100% - 16px); } a:not(:hover) ${keyToCss('generalLabelContainer')} > svg { @@ -17,7 +16,7 @@ a:not(:hover) ${keyToCss('generalLabelContainer')} > svg { } a:not(:hover) ${keyToCss('generalLabelContainer')} > .${spanClass} { - width: 0; + width: 0 !important; } `); @@ -31,8 +30,11 @@ const processLabels = labels => labels.forEach(label => { const textNode = label.firstChild; if (textNode.nodeName !== '#text') return; - const span = dom('span', { class: spanClass }, null, [textNode.textContent]); + const span = dom('span', null, null, [textNode.textContent]); label.replaceChild(span, textNode); + + span.style.width = `${span.getBoundingClientRect().width}px`; + span.classList.add(spanClass); }); const waitForRender = () => From cf498bfe3abd87b52ca7b10adddc1a2bdd310762 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 9 Jul 2023 18:51:02 -0700 Subject: [PATCH 3/9] clarify css --- src/scripts/tweaks/subtle_activity_mutuals.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index 40aee24c3..22bcf4d08 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -3,26 +3,32 @@ import { keyToCss } from '../../util/css_map.js'; import { buildStyle } from '../../util/interface.js'; import { dom } from '../../util/dom.js'; +const labelClass = 'xkit-tweaks-subtle-activity'; const spanClass = 'xkit-tweaks-subtle-activity-span'; const styleElement = buildStyle(` -${keyToCss('generalLabelContainer')} > .${spanClass} { +.${spanClass} { display: inline-block; overflow-x: clip; + + width: var(--rendered-width); } -a:not(:hover) ${keyToCss('generalLabelContainer')} > svg { - margin-left: 0; +a:not(:hover) .${spanClass} { + width: 0; } -a:not(:hover) ${keyToCss('generalLabelContainer')} > .${spanClass} { - width: 0 !important; +a:not(:hover) .${labelClass} > svg { + margin-left: 0; } `); const transitionStyleElement = buildStyle(` -${keyToCss('generalLabelContainer')} > svg, .${spanClass} { - transition: width 0.5s ease, margin 0.5s ease; +.${spanClass} { + transition: width 0.5s ease; +} +.${labelClass} > svg { + transition: margin 0.5s ease; } `); @@ -30,10 +36,12 @@ const processLabels = labels => labels.forEach(label => { const textNode = label.firstChild; if (textNode.nodeName !== '#text') return; + label.classList.add(labelClass); + const span = dom('span', null, null, [textNode.textContent]); label.replaceChild(span, textNode); - span.style.width = `${span.getBoundingClientRect().width}px`; + span.style.setProperty('--rendered-width', `${span.getBoundingClientRect().width}px`); span.classList.add(spanClass); }); @@ -52,6 +60,8 @@ export const clean = async function () { styleElement.remove(); transitionStyleElement.remove(); + $(`.${labelClass}`).removeClass(labelClass); + [...document.querySelectorAll(`.${spanClass}`)].forEach(span => { const textNode = document.createTextNode(span.textContent); span.parentNode.replaceChild(textNode, span); From ce47836a384bbd34ac627df9880ee7445fa92ea0 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 9 Jul 2023 18:56:45 -0700 Subject: [PATCH 4/9] fix animation on activity menu open in prev commit --- src/scripts/tweaks/subtle_activity_mutuals.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index 22bcf4d08..97a12688f 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -3,7 +3,8 @@ import { keyToCss } from '../../util/css_map.js'; import { buildStyle } from '../../util/interface.js'; import { dom } from '../../util/dom.js'; -const labelClass = 'xkit-tweaks-subtle-activity'; +const labelSelector = keyToCss('generalLabelContainer'); + const spanClass = 'xkit-tweaks-subtle-activity-span'; const styleElement = buildStyle(` @@ -18,7 +19,7 @@ a:not(:hover) .${spanClass} { width: 0; } -a:not(:hover) .${labelClass} > svg { +a:not(:hover) ${labelSelector} > svg { margin-left: 0; } `); @@ -27,7 +28,7 @@ const transitionStyleElement = buildStyle(` .${spanClass} { transition: width 0.5s ease; } -.${labelClass} > svg { +${labelSelector} > svg { transition: margin 0.5s ease; } `); @@ -36,8 +37,6 @@ const processLabels = labels => labels.forEach(label => { const textNode = label.firstChild; if (textNode.nodeName !== '#text') return; - label.classList.add(labelClass); - const span = dom('span', null, null, [textNode.textContent]); label.replaceChild(span, textNode); @@ -49,7 +48,7 @@ const waitForRender = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))); export const main = async function () { - pageModifications.register(keyToCss('generalLabelContainer'), processLabels); + pageModifications.register(labelSelector, processLabels); document.documentElement.append(styleElement); waitForRender().then(() => document.documentElement.append(transitionStyleElement)); @@ -60,7 +59,6 @@ export const clean = async function () { styleElement.remove(); transitionStyleElement.remove(); - $(`.${labelClass}`).removeClass(labelClass); [...document.querySelectorAll(`.${spanClass}`)].forEach(span => { const textNode = document.createTextNode(span.textContent); From 698e86e805d0eccd94751e7240150af9a2e5bf42 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 9 Jul 2023 18:59:40 -0700 Subject: [PATCH 5/9] oops my eslint broke again rip --- src/scripts/tweaks/subtle_activity_mutuals.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index 97a12688f..e61a3261e 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -59,7 +59,6 @@ export const clean = async function () { styleElement.remove(); transitionStyleElement.remove(); - [...document.querySelectorAll(`.${spanClass}`)].forEach(span => { const textNode = document.createTextNode(span.textContent); span.parentNode.replaceChild(textNode, span); From c1b0cab9012bdc287f15376897fc1b120f84e388 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 9 Jul 2023 18:59:52 -0700 Subject: [PATCH 6/9] increase animation speed --- src/scripts/tweaks/subtle_activity_mutuals.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index e61a3261e..be022db09 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -26,10 +26,10 @@ a:not(:hover) ${labelSelector} > svg { const transitionStyleElement = buildStyle(` .${spanClass} { - transition: width 0.5s ease; + transition: width 0.2s ease; } ${labelSelector} > svg { - transition: margin 0.5s ease; + transition: margin 0.2s ease; } `); From 7bd7b1231f0088f867fcd814fa2d33b46aeaab02 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 26 Mar 2024 02:30:17 -0700 Subject: [PATCH 7/9] fix selector --- src/scripts/tweaks/subtle_activity_mutuals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index be022db09..dfa47afd1 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -3,7 +3,7 @@ import { keyToCss } from '../../util/css_map.js'; import { buildStyle } from '../../util/interface.js'; import { dom } from '../../util/dom.js'; -const labelSelector = keyToCss('generalLabelContainer'); +const labelSelector = keyToCss('followingBadgeContainer', 'mutualsBadgeContainer'); const spanClass = 'xkit-tweaks-subtle-activity-span'; From a9ac3cb3c7637604986b16099167b7b68e18e657 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 26 Mar 2024 02:33:58 -0700 Subject: [PATCH 8/9] don't remove dom nodes never remove dom nodes. --- src/scripts/tweaks/subtle_activity_mutuals.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scripts/tweaks/subtle_activity_mutuals.js b/src/scripts/tweaks/subtle_activity_mutuals.js index dfa47afd1..996e056a9 100644 --- a/src/scripts/tweaks/subtle_activity_mutuals.js +++ b/src/scripts/tweaks/subtle_activity_mutuals.js @@ -38,7 +38,8 @@ const processLabels = labels => labels.forEach(label => { if (textNode.nodeName !== '#text') return; const span = dom('span', null, null, [textNode.textContent]); - label.replaceChild(span, textNode); + label.insertBefore(span, textNode); + textNode.textContent = ''; span.style.setProperty('--rendered-width', `${span.getBoundingClientRect().width}px`); span.classList.add(spanClass); From 0de8ddf6c0da9c4fa8fb2610276f5e9d752cd007 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 29 Apr 2024 03:51:34 -0700 Subject: [PATCH 9/9] update required browser version Co-Authored-By: April Sylph <28949509+AprilSylph@users.noreply.github.com> --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index 8902a972b..858ca3f28 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -65,7 +65,7 @@ } ], - "minimum_chrome_version": "89", + "minimum_chrome_version": "90", "browser_specific_settings": { "gecko": { "strict_min_version": "89.0a1"