Skip to content

Commit 571346b

Browse files
committed
Custom Monitor Opacity
1 parent d9d2164 commit 571346b

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

extras/popup/popup.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ a {
122122
}
123123

124124
.feature input {
125-
color: var(--color);
125+
color: var(--primary-color);
126126
background-color: var(--feature-input-bg);
127127
padding-left: 1rem !important;
128128
}
@@ -233,7 +233,7 @@ a {
233233
border-radius: 1rem;
234234
outline: none;
235235
border: 0px;
236-
color: white;
236+
color: var(--primary-color);
237237
background-color: var(--feature-input-bg);
238238
}
239239

extras/popup/popup.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ async function getFeatures() {
769769
];
770770
input.value = optionData || "";
771771
input.placeholder = `Enter ${input.type}`;
772+
input.dataset.validators = JSON.stringify(option.validators || {})
772773
var optionDiv = document.createElement("div");
773774
optionDiv.className = "option";
774775
var label = document.createElement("label");
@@ -799,6 +800,7 @@ async function getFeatures() {
799800
var validation = JSON.parse(atob(this.dataset.validation));
800801
var ready = true;
801802
var input = this;
803+
let validators = JSON.parse(this.dataset.validators)
802804
validation.forEach(function (validate) {
803805
if (ready) {
804806
input.style.outline = "none";
@@ -822,6 +824,16 @@ async function getFeatures() {
822824
}
823825
});
824826
if (ready) {
827+
if (validators.min) {
828+
if (this.value < validators.min) {
829+
this.value = validators.min
830+
}
831+
}
832+
if (validators.max) {
833+
if (this.value > validators.max) {
834+
this.value = validators.max
835+
}
836+
}
825837
if (this.type !== "checkbox") {
826838
finalValue = this.value;
827839
} else {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "Custom Monitor Opacity",
3+
"description": "Set the opacity of variables and lists on the stage to a custom number.",
4+
"credits": [
5+
{ "username": "rgantzos", "url": "https://scratch.mit.edu/users/rgantzos/" }
6+
],
7+
"tags": [],
8+
"scripts": [{ "file": "script.js", "runOn": "/projects/*" }],
9+
"dynamic": true,
10+
"options": [
11+
{
12+
"id": "monitor-opacity",
13+
"name": "Monitor Opacity (0% - 100%)",
14+
"type": 2,
15+
"validators": {
16+
"min": 0,
17+
"max": 100
18+
}
19+
}
20+
],
21+
"type": ["Website", "Editor"]
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default async function ({ feature, console }) {
2+
let MONITORS = []
3+
4+
feature.page.waitForElements("div.monitor-overlay[class*='monitor-list_monitor-list_']", function(monitors) {
5+
MONITORS.push(monitors)
6+
7+
monitors.style.opacity = feature.self.enabled ? (((feature.settings.get("monitor-opacity")) || 0) / 100).toString() : "100%"
8+
})
9+
10+
function updateMonitors(opacity) {
11+
for (var i in MONITORS) {
12+
MONITORS[i].style.opacity = feature.self.enabled ? (((feature.settings.get("monitor-opacity")) || 0) / 100).toString() : "100%"
13+
}
14+
}
15+
16+
feature.addEventListener("enabled", updateMonitors)
17+
feature.addEventListener("disabled", updateMonitors)
18+
feature.settings.addEventListener("changed", updateMonitors)
19+
}

features/features.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[
2+
{
3+
"version": 2,
4+
"id": "change-monitor-opacity",
5+
"versionAdded": "v4.0.0"
6+
},
27
{
38
"version": 2,
49
"id": "custom-explore",

0 commit comments

Comments
 (0)