From a38f2356c097951254aaef5539248642635ba167 Mon Sep 17 00:00:00 2001 From: rgantzos <86856959+rgantzosonscratch@users.noreply.github.com> Date: Tue, 9 Aug 2022 17:49:54 -0700 Subject: [PATCH] Update version info, change order of features, make popup work in dark mode, and update project timer to fix bugs --- extras/new.js | 4 +- features/features.json | 208 +++++++++++++++++++------------------- features/project-timer.js | 82 ++++++++------- manifest.json | 2 +- 4 files changed, 147 insertions(+), 149 deletions(-) diff --git a/extras/new.js b/extras/new.js index 7ed6683d..ecb92764 100644 --- a/extras/new.js +++ b/extras/new.js @@ -1,8 +1,8 @@ -createModal("What's New in ScratchTools v2.12.0", "This is a big version for the editor. We've added a feature that lets you collapse scripts. You can also replace the sprite grid with a list of the project's sprites, each one showing the block count and x/y position. On project pages, you can see if a project is on trending, and if so, where on trending. We also fixed bugs with the delete all sprites, last key pressed, and project timer features.") +createModal("What's New in ScratchTools v2.13.0", "This new version includes a lot of new features! We've added a sprite-specific clone counter, the ability to scroll through individual list items, a block logger, an FPS counter, and more! We've even added in some easter eggs- maybe you can find them!") function createModal(title, description) { var div = document.createElement('div') div.className = 'ReactModalPortal ScratchToolsNew' - div.innerHTML = `
` + div.innerHTML = ` ` document.body.appendChild(div) var style = document.createElement('style') style.innerHTML = ` diff --git a/features/features.json b/features/features.json index 11107421..0b751a41 100644 --- a/features/features.json +++ b/features/features.json @@ -1,12 +1,12 @@ [ { - "title": "FPS Counter", - "description": "Displays the current FPS for the project.", - "credits": ["rgantzos", "ThePro255", "Tacodude7729"], - "urls": ["https://scratch.mit.edu/users/rgantzos/", "https://scratch.mit.edu/users/ThePro255/", "https://github.com/Tacodude7729"], - "file": "fps", - "tags": ["New", "Beta"], - "type": ["Website", "Editor"] + "title": "Sprite Clone Counter", + "description": "Displays the clone count for each individual sprite.", + "credits": ["rgantzos", "GrahamBurger"], + "urls": ["https://scratch.mit.edu/users/rgantzos/", "https://scratch.mit.edu/users/GrahamBurger/"], + "file": "sprite-clones", + "tags": ["New", "Recommended"], + "type": ["Editor"] }, { "title": "Block Log", @@ -17,15 +17,6 @@ "tags": ["New","Featured"], "type": ["Editor"] }, - { - "title": "Message Indicator Red for Admin Messages", - "description": "If you have an admin notification from the Scratch Team, the message indicator in the navigation bar will display red instead of orange.", - "credits": ["rgantzos"], - "urls": ["https://scratch.mit.edu/users/rgantzos/"], - "file": "admin-notifications", - "tags": ["New"], - "type": ["Website"] - }, { "title": "Scrollable List Items", "description": "List items that have a value longer than the width of the list itself will get cut off. Now, you can scroll left and right through the list item.", @@ -36,13 +27,22 @@ "type": ["Website", "Editor"] }, { - "title": "Sprite Clone Counter", - "description": "Displays the clone count for each individual sprite.", - "credits": ["rgantzos", "GrahamBurger"], - "urls": ["https://scratch.mit.edu/users/rgantzos/", "https://scratch.mit.edu/users/GrahamBurger/"], - "file": "sprite-clones", - "tags": ["New", "Recommended"], - "type": ["Editor"] + "title": "FPS Counter", + "description": "Displays the current FPS for the project.", + "credits": ["rgantzos", "ThePro255", "Tacodude7729"], + "urls": ["https://scratch.mit.edu/users/rgantzos/", "https://scratch.mit.edu/users/ThePro255/", "https://github.com/Tacodude7729"], + "file": "fps", + "tags": ["New", "Beta"], + "type": ["Website", "Editor"] + }, + { + "title": "Message Indicator Red for Admin Messages", + "description": "If you have an admin notification from the Scratch Team, the message indicator in the navigation bar will display red instead of orange.", + "credits": ["rgantzos"], + "urls": ["https://scratch.mit.edu/users/rgantzos/"], + "file": "admin-notifications", + "tags": ["New"], + "type": ["Website"] }, { "title": "Rickroll", @@ -53,6 +53,52 @@ "tags": ["New", "Egg"], "type": ["Website"] }, + { + "title": "Custom Website Font", + "description": "On the Scratch website, you can set the font to whatever font you want, as long as it is on the Google Fonts website. This is case-sensitive.", + "credits": ["Scratchfangs", "devxan", "rgantzos"], + "urls": ["https://scratch.mit.edu/users/Scratchfangs/", "https://github.com/devxan", "https://scratch.mit.edu/users/rgantzos/"], + "file": "custom-fonts", + "tags": ["Featured"], + "type": ["Website", "Theme"], + "world": "ISOLATED" + }, + { + "title": "Project Timer", + "description": "Displays the amount of time (in seconds) that the project has been running for.", + "credits": ["rgantzos"], + "urls": ["https://scratch.mit.edu/users/rgantzos/"], + "file": "project-timer", + "tags": ["Featured"], + "type": ["Editor"] + }, + { + "title": "Colored Editor Comments", + "description": "Colors comments in the editor based on the color of their parent block.", + "credits": ["rgantzos"], + "urls": ["https://scratch.mit.edu/users/rgantzos/"], + "file": "colored-comments", + "tags": ["Featured"], + "type": ["Editor", "Theme"] + }, + { + "title": "Recently Viewed Projects", + "description": "Adds a tab to the My Stuff page where you can see a list of the projects that you have recently viewed.", + "credits": ["Karve_", "rgantzos"], + "urls": ["https://scratch.mit.edu/users/Karve_/", "https://scratch.mit.edu/users/rgantzos/"], + "file": "recently-viewed-projects", + "tags": ["Featured", "Recommended"], + "type": ["Website"] + }, + { + "title": "Anti Generic", + "description": "On the explore and trending pages, this beta feature automatically hides repetitive projects, along with projects that it expects are generic. This includes projects with a lot of tags, common names, and project duplicates.", + "credits": ["Bob the Potato wit Drip Jr.", "rgantzos"], + "urls": ["https://scratch.mit.edu/users/JefferyTheSuperKat/", "https://scratch.mit.edu/users/rgantzos/"], + "file": "anti-generic", + "tags": ["Beta", "Featured"], + "type": ["Website", "Theme"] + }, { "title": "Collapse Blocks", "description": "Right-click block menus in the editor include a button that will let you collapse the selected block.", @@ -62,6 +108,33 @@ "tags": ["Recommended"], "type": ["Editor"] }, + { + "title": "Set Featured Project", + "description": "On any project page, you can easily set your profile's featured project with the click of a button- even unshared projects.", + "credits": ["rgantzos"], + "urls": ["https://scratch.mit.edu/users/rgantzos/"], + "file": "set-featured-project", + "tags": ["Recommended"], + "type": ["Website"] + }, + { + "title": "ScratchFormat", + "description": "Format your comments with bold, italic, and more! The comments will look amazing to everyone using ScratchTools.", + "credits": ["petabyt", "Daniel4-Scratch"], + "urls": ["https://danielc.dev/", "https://github.com/Daniel4-Scratch"], + "file": "scratchformat", + "tags": ["Recommended"], + "type": ["Website"] + }, + { + "title": "Expand Editor", + "description": "Use the ctrl+e to easily switch between the default block editor view and one that hides the stage to expand editor itself!", + "credits": ["Jazza", "rgantzos"], + "urls": ["https://github.com/Jazza-231", "https://scratch.mit.edu/users/rgantzos/"], + "file": "expand-editor", + "tags": ["Recommended"], + "type": ["Editor"] + }, { "title": "Sprite List", "description": "Replaces the sprite grid in the editor with a list that includes the block count and position of the sprite.", @@ -116,15 +189,6 @@ "tags": [], "type": ["Website"] }, - { - "title": "Set Featured Project", - "description": "On any project page, you can easily set your profile's featured project with the click of a button- even unshared projects.", - "credits": ["rgantzos"], - "urls": ["https://scratch.mit.edu/users/rgantzos/"], - "file": "set-featured-project", - "tags": ["Recommended"], - "type": ["Website"] - }, { "title": "Pin Projects to My Stuff", "description": "Pin one of your projects to the top of your My Stuff page with the click of a button! You can unpin your pinned project or switch out your pinned project for another one as well!", @@ -135,16 +199,6 @@ "type": ["Website"], "world": "ISOLATED" }, - { - "title": "Custom Website Font", - "description": "On the Scratch website, you can set the font to whatever font you want, as long as it is on the Google Fonts website. This is case-sensitive.", - "credits": ["Scratchfangs", "devxan", "rgantzos"], - "urls": ["https://scratch.mit.edu/users/Scratchfangs/", "https://github.com/devxan", "https://scratch.mit.edu/users/rgantzos/"], - "file": "custom-fonts", - "tags": ["Featured"], - "type": ["Website", "Theme"], - "world": "ISOLATED" - }, { "title": "Last Key Pressed", "description": "On any project page and in the editor, you can view the last key that you have pressed while on that project, according to the project itself! This is good for games such as platformers.", @@ -172,24 +226,6 @@ "tags": [], "type": ["Website"] }, - { - "title": "ScratchFormat", - "description": "Format your comments with bold, italic, and more! The comments will look amazing to everyone using ScratchTools.", - "credits": ["petabyt", "Daniel4-Scratch"], - "urls": ["https://danielc.dev/", "https://github.com/Daniel4-Scratch"], - "file": "scratchformat", - "tags": ["Recommended"], - "type": ["Website"] - }, - { - "title": "Project Timer", - "description": "Displays the amount of time (in seconds) that the project has been running for.", - "credits": ["rgantzos"], - "urls": ["https://scratch.mit.edu/users/rgantzos/"], - "file": "project-timer", - "tags": ["Featured", "Beta"], - "type": ["Editor"] - }, { "title": "Go to Parent Button", "description": "In the editor for any project that is a remix, you can click a button to go to the editor in the parent project.", @@ -208,22 +244,13 @@ "tags": [], "type": ["Website"] }, - { - "title": "Colored Editor Comments", - "description": "Colors comments in the editor based on the color of their parent block.", - "credits": ["rgantzos"], - "urls": ["https://scratch.mit.edu/users/rgantzos/"], - "file": "colored-comments", - "tags": ["Featured"], - "type": ["Editor", "Theme"] - }, { "title": "Block Users", "description": "Hide messages on the messages page that are created by users that you have blocked (includes a block page).", "credits": ["rgantzos", "Scratchfangs"], "urls": ["https://scratch.mit.edu/users/rgantzos/", "https://scratch.mit.edu/users/rgantzos/"], "file": "block-messages", - "tags": ["Featured"], + "tags": [], "world": "ISOLATED", "type": ["Website"] }, @@ -233,7 +260,7 @@ "credits": ["infinitytec"], "urls": ["https://github.com/infinitytec"], "file": "editor-dark-mode", - "tags": ["Featured"], + "tags": [], "type": ["Editor", "Theme"] }, { @@ -260,52 +287,25 @@ "credits": ["_nix"], "urls": ["https://scratch.mit.edu/users/_nix/"], "file": "colored-messages", - "tags": ["Recommended"], + "tags": [], "type": ["Website", "Theme"] }, - { - "title": "Expand Editor", - "description": "Use the ctrl+e to easily switch between the default block editor view and one that hides the stage to expand editor itself!", - "credits": ["Jazza", "rgantzos"], - "urls": ["https://github.com/Jazza-231", "https://scratch.mit.edu/users/rgantzos/"], - "file": "expand-editor", - "tags": ["Recommended"], - "type": ["Editor"] - }, { "title": "Full Project Title", "description": "On profile pages, hover over any project title to show the full title.", "credits": ["rgantzos"], "urls": ["https://scratch.mit.edu/users/rgantzos"], "file": "full-title", - "tags": ["Recommended"], - "type": ["Website"] - }, - { - "title": "Recently Viewed Projects", - "description": "Adds a tab to the My Stuff page where you can see a list of the projects that you have recently viewed.", - "credits": ["Karve_", "rgantzos"], - "urls": ["https://scratch.mit.edu/users/Karve_/", "https://scratch.mit.edu/users/rgantzos/"], - "file": "recently-viewed-projects", - "tags": ["Featured", "Recommended"], + "tags": [], "type": ["Website"] }, - { - "title": "Anti Generic", - "description": "On the explore and trending pages, this beta feature automatically hides repetitive projects, along with projects that it expects are generic. This includes projects with a lot of tags, common names, and project duplicates.", - "credits": ["Bob the Potato wit Drip Jr.", "rgantzos"], - "urls": ["https://scratch.mit.edu/users/JefferyTheSuperKat/", "https://scratch.mit.edu/users/rgantzos/"], - "file": "anti-generic", - "tags": ["Beta", "Featured"], - "type": ["Website", "Theme"] - }, { "title": "April Fools 2022", "description": "Brings back the special modes from the 2022 April Fools Day!", "credits": ["rgantzos"], "urls": ["https://scratch.mit.edu/users/rgantzos/"], "file": "april-fools", - "tags": ["Featured", "Egg"], + "tags": ["Egg"], "type": ["Editor", "Theme"] }, { @@ -314,7 +314,7 @@ "credits": ["rgantzos"], "urls": ["https://scratch.mit.edu/users/rgantzos"], "file": "project-links", - "tags": ["Featured"], + "tags":[], "type": ["Website"] }, { @@ -323,7 +323,7 @@ "credits": ["Scratchfangs", "rgantzos"], "urls": ["https://scratch.mit.edu/users/Scratchfangs", "https://scratch.mit.edu/users/rgantzos"], "file": "fixed-box", - "tags": ["Featured"], + "tags": [], "type": ["Website", "Theme"] }, { @@ -332,7 +332,7 @@ "credits": ["rgantzos"], "urls": ["https://scratch.mit.edu/users/rgantzos"], "file": "user-bio", - "tags": ["Featured"], + "tags": [], "type": ["Website"] }, { diff --git a/features/project-timer.js b/features/project-timer.js index d3869fc7..6beb8f42 100644 --- a/features/project-timer.js +++ b/features/project-timer.js @@ -1,51 +1,49 @@ if (window.location.href.includes('https://scratch.mit.edu/projects/')) { -var times = [] -var stop = [] -ScratchTools.Scratch.vm.runtime.on('PROJECT_RUN_START', function() { - times = [] - stop = [] - times.push(ScratchTools.Scratch.vm.runtime.currentMSecs) - getCurrentM() -}) -ScratchTools.Scratch.vm.runtime.on('PROJECT_RUN_STOP', function() { - stop.push('') -}) -function getCurrentM() { - if (stop.length === 0) { - if ((ScratchTools.Scratch.vm.runtime.currentMSecs-times[times.length-1])/1000 !== NaN) { - document.querySelector('div.timer.scratchtools').textContent = `${(ScratchTools.Scratch.vm.runtime.currentMSecs-times[times.length-1])/1000} secs` - setTimeout(getCurrentM, 50) + if (document.scratchtoolsTimer !== undefined && document.scratchtoolsTimer !== null) { + var bar = document.createElement('div') + bar.className = "timer scratchtools" + bar.style.margin = '0' +bar.style.marginTop = '7px' +bar.style.marginLeft = '5px' +document.querySelectorAll('div').forEach(function(el) { + if (el.className.includes('controls_controls-container_')) { + if (document.querySelector('div.timer.scratchtools') === null) { +el.appendChild(bar) + bar.textContent = '0 secs' + } } +}) } -} - -var bar = document.createElement('div') +ScratchTools.Scratch.vm.runtime.on('PROJECT_RUN_START', function() { + if (document.querySelector('div.timer.scratchtools') === null) { + var bar = document.createElement('div') bar.className = "timer scratchtools" bar.style.margin = '0' bar.style.marginTop = '7px' bar.style.marginLeft = '5px' - var style = document.createElement('style') - style.innerHTML = ` - div.timer.scratchtools { - top: 50%; - left: 50%; - -ms-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - } - ` - //document.body.appendChild(style) - checkForTimerPosition() - function checkForTimerPosition() { - document.querySelectorAll('div').forEach(function(el) { - if (el.className.includes('controls_controls-container_')) { - if (document.querySelector('div.timer.scratchtools') === null) { - el.appendChild(bar) - bar.textContent = '0 secs' - } - } - }) - if (document.querySelector('div.timer.scratchtools') === null) { - setTimeout(checkForTimerPosition, 100) - } +document.querySelectorAll('div').forEach(function(el) { + if (el.className.includes('controls_controls-container_')) { + if (document.querySelector('div.timer.scratchtools') === null) { +el.appendChild(bar) + bar.textContent = '0 secs' } } +}) + } + document.scratchtoolsTimer = ScratchTools.Scratch.vm.runtime.currentMSecs +}) +ScratchTools.Scratch.vm.runtime.on("PROJECT_RUN_STOP", function() { + document.scratchtoolsTimer = null + if (document.querySelector('div.timer.scratchtools') !== null) { + document.querySelector('div.timer.scratchtools').remove() + } +}) +setInterval(getCurrentM, 50) +function getCurrentM() { + if (document.querySelector('div.timer.scratchtools') !== null) { + if (document.scratchtoolsTimer !== undefined) { + document.querySelector('div.timer.scratchtools').textContent = `${(ScratchTools.Scratch.vm.runtime.currentMSecs-document.scratchtoolsTimer)/1000} secs` + } +} +} +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 30f3a854..162a6af4 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "short_name": "ScratchTools", "manifest_version": 3, "version": "2.13.0", - "version_name": "2.13.0-beta", + "version_name": "2.13.0", "description": "Great tools to make Scratching easier!", "author": "rgantzos", "background": {