Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions features/disable-cloud/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "Disable Cloud",
"description": "Allows you to disable cloud data on any project. This will still receive cloud data information, but will not send any.",
"credits": [
{ "username": "rgantzos", "url": "https://scratch.mit.edu/users/rgantzos/" }
],
"scripts": [{ "file": "script.js", "runOn": "/projects/*" }],
"styles": [{ "file": "style.css", "runOn": "/projects/*" }],
"type": ["Editor"],
"tags": ["New", "Featured"],
"dynamic": true
}

48 changes: 48 additions & 0 deletions features/disable-cloud/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export default async function ({ feature, console }) {
feature.traps.gui().projectState.cloudStatus = "ENABLED";

ScratchTools.waitForElements(".extension-chip", function (chip) {
if (!chip.firstChild.src.endsWith("/svgs/project/clouddata.svg")) return;
if (chip.querySelector(".ste-cloud-disable")) return;

let content = chip.querySelector(".extension-content");

let outer = document.createElement("div");
outer.className = "ste-action-holder";
outer.appendChild(content.lastChild);

let div = document.createElement("div");
div.className = "extension-action ste-cloud-disable";
outer.appendChild(div);

feature.self.hideOnDisable(div)

let span = document.createElement("span");
span.textContent = "Disable";
div.appendChild(span);

span.addEventListener("click", function () {
if (span.textContent === "Disable") {
span.textContent = "Enable";
feature.traps.gui().projectState.cloudStatus = "DISABLED";
} else {
span.textContent = "Disable";
feature.traps.gui().projectState.cloudStatus = "ENABLED";
}
});

content.appendChild(outer);
});

const nativeWsSend = WebSocket.prototype.send;
WebSocket.prototype.send = function (...args) {
let data = JSON.parse(args[0]);
if (
data.method === "set" &&
feature.traps.gui().projectState.cloudStatus === "DISABLED" &&
feature.self.enabled
)
return;
return nativeWsSend.call(this, ...args);
};
}
12 changes: 12 additions & 0 deletions features/disable-cloud/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.ste-cloud-disable {
height: 14px;
margin-left: .25rem;
cursor: pointer;
padding-top: 1px !important;
position: relative;
top: 1px;
}

.extension-chip .extension-action {
display: inline-flex !important;
}
5 changes: 5 additions & 0 deletions features/features.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"version": 2,
"id": "disable-cloud",
"versionAdded": "v4.0.0"
},
{
"version": 2,
"id": "webp-uploads",
Expand Down