From 3236b75df38d8fd2a4a7bd2c46e85bb45208d8db Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:43:30 -0500 Subject: [PATCH 01/10] Default To Bitmap --- features/bitmap-default/data.json | 12 ++++++++++++ features/bitmap-default/script.js | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 features/bitmap-default/data.json create mode 100644 features/bitmap-default/script.js diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json new file mode 100644 index 00000000..22a5e7df --- /dev/null +++ b/features/bitmap-default/data.json @@ -0,0 +1,12 @@ +{ + "title": "Default to Bitmap", + "description": "Automatically switches to bitmap mode in the costume editor when opened.", + "credits": [ + { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } + ], + "type": ["Editor"], + "tags": ["New", "Featured"], + "dynamic": true, + "scripts": [{ "file": "script.js", "runOn": "/editor/*" }] + } + \ No newline at end of file diff --git a/features/bitmap-default/script.js b/features/bitmap-default/script.js new file mode 100644 index 00000000..1594e896 --- /dev/null +++ b/features/bitmap-default/script.js @@ -0,0 +1,8 @@ +export default async function ({ feature, console }) { + ScratchTools.waitForElements(".paint-editor_bitmap-button_OEHDO", (bitmapButton) => { + if (feature.self.enabled) { + bitmapButton.click(); + } + }); + } + \ No newline at end of file From a97a1dc795a67331ade30734508828fa4905833a Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:44:03 -0500 Subject: [PATCH 02/10] Update features.json --- features/features.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/features.json b/features/features.json index caa770ce..45f9b560 100644 --- a/features/features.json +++ b/features/features.json @@ -1,4 +1,9 @@ [ + { + "version": 2, + "id": "bitmap-default", + "versionAdded": "v4.0.0" + }, { "version": 2, "id": "outline-shape-options", From 7712806131ec8e0d0ed35c57c5918242f319e982 Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:49:41 -0500 Subject: [PATCH 03/10] Better method --- features/bitmap-default/script.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/features/bitmap-default/script.js b/features/bitmap-default/script.js index 1594e896..284d98c0 100644 --- a/features/bitmap-default/script.js +++ b/features/bitmap-default/script.js @@ -1,8 +1,11 @@ -export default async function ({ feature, console }) { - ScratchTools.waitForElements(".paint-editor_bitmap-button_OEHDO", (bitmapButton) => { - if (feature.self.enabled) { +export default async function ({ feature }) { + ScratchTools.waitForElements("body", () => { + const observer = new MutationObserver(() => { + const bitmapButton = document.querySelector(".paint-editor_bitmap-button_OEHDO"); + if (bitmapButton && feature.self.enabled) { bitmapButton.click(); } }); - } - \ No newline at end of file + observer.observe(document.body, { childList: true, subtree: true }); + }); +} From 7dbaaf02ce6a750b5672250a334e82f01f4e62c0 Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 21:54:20 -0500 Subject: [PATCH 04/10] Update Credits --- features/bitmap-default/data.json | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json index 22a5e7df..fd4aefcc 100644 --- a/features/bitmap-default/data.json +++ b/features/bitmap-default/data.json @@ -1,12 +1,14 @@ { - "title": "Default to Bitmap", - "description": "Automatically switches to bitmap mode in the costume editor when opened.", - "credits": [ - { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } - ], - "type": ["Editor"], - "tags": ["New", "Featured"], - "dynamic": true, - "scripts": [{ "file": "script.js", "runOn": "/editor/*" }] - } - \ No newline at end of file + "title": "Default to Bitmap", + "description": "Automatically switches to bitmap mode in the costume editor when opened.", + "credits": [ + { "username": "Medians", "url": "https://scratch.mit.edu/users/Medians/" }, + { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } + ], + "type": ["Editor"], + "tags": ["New", "Featured"], + "dynamic": true, + "scripts": [{ "file": "script.js", "runOn": "/editor/*" }] +} + + From 1fca5af77958a4356a304d8470fa3d6e899d69df Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 23:25:42 -0500 Subject: [PATCH 05/10] Reword --- features/bitmap-default/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json index fd4aefcc..665abb83 100644 --- a/features/bitmap-default/data.json +++ b/features/bitmap-default/data.json @@ -1,6 +1,6 @@ { "title": "Default to Bitmap", - "description": "Automatically switches to bitmap mode in the costume editor when opened.", + "description": "Makes bitmap the default mode in the costume editor", "credits": [ { "username": "Medians", "url": "https://scratch.mit.edu/users/Medians/" }, { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } From b82865b5559b963475a36d01ddac1ba24855c142 Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 23:26:35 -0500 Subject: [PATCH 06/10] Ok, that's better! --- features/bitmap-default/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json index 665abb83..d6fefa1d 100644 --- a/features/bitmap-default/data.json +++ b/features/bitmap-default/data.json @@ -1,6 +1,6 @@ { "title": "Default to Bitmap", - "description": "Makes bitmap the default mode in the costume editor", + "description": "Updates the default mode to bitmap in the costume editor.", "credits": [ { "username": "Medians", "url": "https://scratch.mit.edu/users/Medians/" }, { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } From ab3a22930ab6e69c2f14d42d438b57e0ec4beed5 Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Sun, 29 Dec 2024 23:28:00 -0500 Subject: [PATCH 07/10] I'm a perfectionist, I know --- features/bitmap-default/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json index d6fefa1d..d5968ecd 100644 --- a/features/bitmap-default/data.json +++ b/features/bitmap-default/data.json @@ -1,6 +1,6 @@ { "title": "Default to Bitmap", - "description": "Updates the default mode to bitmap in the costume editor.", + "description": "Sets the default mode to bitmap in the costume editor.", "credits": [ { "username": "Medians", "url": "https://scratch.mit.edu/users/Medians/" }, { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } From 615eb744342c26d05eb787ab89a777c9e38a622a Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:00:30 -0500 Subject: [PATCH 08/10] Update data.json --- features/bitmap-default/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/bitmap-default/data.json b/features/bitmap-default/data.json index d5968ecd..6af5d496 100644 --- a/features/bitmap-default/data.json +++ b/features/bitmap-default/data.json @@ -2,7 +2,7 @@ "title": "Default to Bitmap", "description": "Sets the default mode to bitmap in the costume editor.", "credits": [ - { "username": "Medians", "url": "https://scratch.mit.edu/users/Medians/" }, + { "username": "medians", "url": "https://scratch.mit.edu/users/medians/" }, { "username": "MaterArc", "url": "https://scratch.mit.edu/users/MaterArc/" } ], "type": ["Editor"], From 729b056777385b19fec1d4d8b024259eb31c8cd3 Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:40:29 -0500 Subject: [PATCH 09/10] Dynamic --- features/bitmap-default/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/bitmap-default/script.js b/features/bitmap-default/script.js index 284d98c0..d9c95a5c 100644 --- a/features/bitmap-default/script.js +++ b/features/bitmap-default/script.js @@ -2,8 +2,9 @@ export default async function ({ feature }) { ScratchTools.waitForElements("body", () => { const observer = new MutationObserver(() => { const bitmapButton = document.querySelector(".paint-editor_bitmap-button_OEHDO"); - if (bitmapButton && feature.self.enabled) { + if (bitmapButton && feature.self.enabled && !bitmapButton.classList.contains("clicked")) { bitmapButton.click(); + bitmapButton.classList.add("clicked"); } }); observer.observe(document.body, { childList: true, subtree: true }); From ea07bd637910e00c14563775d58749a06c334fad Mon Sep 17 00:00:00 2001 From: MaterArc <105017592+MaterArc@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:41:57 -0500 Subject: [PATCH 10/10] Revert --- features/bitmap-default/script.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/bitmap-default/script.js b/features/bitmap-default/script.js index d9c95a5c..284d98c0 100644 --- a/features/bitmap-default/script.js +++ b/features/bitmap-default/script.js @@ -2,9 +2,8 @@ export default async function ({ feature }) { ScratchTools.waitForElements("body", () => { const observer = new MutationObserver(() => { const bitmapButton = document.querySelector(".paint-editor_bitmap-button_OEHDO"); - if (bitmapButton && feature.self.enabled && !bitmapButton.classList.contains("clicked")) { + if (bitmapButton && feature.self.enabled) { bitmapButton.click(); - bitmapButton.classList.add("clicked"); } }); observer.observe(document.body, { childList: true, subtree: true });