-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #696 from rgantzos/main
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"title": "Remove Project Button", | ||
"description": "Adds a button to projects in studios that allows you to easily remove it from the studio without opening the menu.", | ||
"credits": [ | ||
{ | ||
"username": "rgantzos", | ||
"url": "https://scratch.mit.edu/users/rgantzos/" | ||
} | ||
], | ||
"dynamic": true, | ||
"styles": [{ "file": "style.css", "runOn": "/studios/*" }], | ||
"scripts": [{ "file": "script.js", "runOn": "/studios/*" }], | ||
"tags": ["New"], | ||
"type": ["Website"], | ||
"resources": [{ "name": "remove-project-trash", "path": "/remove.svg" }] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export default async function ({ feature, console }) { | ||
ScratchTools.waitForElements( | ||
".studio-project-bottom .overflow-menu-container", | ||
function (menu) { | ||
let img = document.createElement("img"); | ||
img.src = feature.self.getResource("remove-project-trash"); | ||
img.classList.add("ste-remove-project"); | ||
|
||
feature.self.hideOnDisable(img); | ||
|
||
menu.appendChild(img); | ||
|
||
img.addEventListener("click", async function () { | ||
let projectId = menu | ||
.closest(".studio-project-tile") | ||
.firstChild.href.split("/")[4]; | ||
await fetch( | ||
"https://api.scratch.mit.edu/studios/" + | ||
window.location.pathname.split("/")[2] + | ||
"/project/" + | ||
projectId, | ||
{ | ||
headers: { | ||
"x-token": feature.redux.getState().session.session.user.token, | ||
}, | ||
method: "DELETE", | ||
} | ||
); | ||
menu.closest(".studio-project-tile").remove(); | ||
}); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.overflow-menu-container .overflow-menu-trigger { | ||
display: none; | ||
} | ||
|
||
.ste-remove-project { | ||
height: 2rem; | ||
position: relative; | ||
top: 0.35rem; | ||
cursor: pointer; | ||
transition: transform .3s, opacity .3s; | ||
opacity: .6; | ||
transform: scale(90%); | ||
margin-right: .5rem; | ||
} | ||
|
||
.ste-remove-project:hover { | ||
transform: scale(95%); | ||
opacity: 1; | ||
} |