Skip to content

Commit eb639f4

Browse files
committed
Fix some stuff
1 parent fdc1995 commit eb639f4

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

extras/popup/popup.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,10 @@ span.new-feature-tag.beta {
470470

471471
.option-selection {
472472
text-align: right;
473-
width: 100%;
473+
width: calc(100% - 1rem);
474+
display: flex;
475+
overflow-wrap: break-word;
476+
flex-wrap: wrap;
474477
}
475478

476479
.option-selection span {
@@ -483,6 +486,15 @@ span.new-feature-tag.beta {
483486
background-color: transparent;
484487
color: var(--secondary-color);
485488
transition: background-color .3s, border .3s, color .3s;
489+
display: inline-block;
490+
word-break: break-word;
491+
white-space: nowrap;
492+
flex: 1 0 auto;
493+
text-align: center;
494+
}
495+
496+
.option label {
497+
margin-right: 1rem;
486498
}
487499

488500
.option-selection span.option-selected {

features/custom-explore/data.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
"scripts": [
2222
{
2323
"file": "script.js",
24-
"runOn": "/explore/projects/*||/"
24+
"runOn": "/*"
2525
}
2626
],
2727
"dynamic": true,
2828
"options": [
2929
{
30-
"id": "custom-tab",
31-
"name": "",
30+
"id": "custom-explore-tab",
31+
"name": "Tab",
3232
"type": 4,
3333
"options": [
3434
{

features/custom-explore/script.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
export default async function({ feature, console }) {
2-
let tabName = ScratchTools.Storage["customtab"];
2+
let ELEMENTS = []
3+
let type = feature.settings.get("custom-explore-tab") || "Animations"
4+
5+
ScratchTools.waitForElements("a[href='/explore/projects/'], a[href='/explore/projects'], a[href='/explore/projects/all'], a[href='/explore/projects/all/']", function(a) {
6+
if (a.parentElement.className.includes("sub-nav categories")) return;
7+
ELEMENTS.push(a)
8+
9+
a.href = feature.self.enabled ? `/explore/projects/${type.toLowerCase()}/` : "/explore/projects/"
10+
})
311

4-
function updateRedirect() {
5-
const exploreLink = document.querySelector('li.link.explore > a');
6-
if (exploreLink && window.location.href === 'https://scratch.mit.edu/explore/projects/all') {
7-
exploreLink.href = `https://scratch.mit.edu/explore/projects/${tabName}`;
8-
window.location.href = exploreLink.href;
12+
function updateRedirects() {
13+
for (var i in ELEMENTS) {
14+
ELEMENTS[i].href = feature.self.enabled ? `/explore/projects/${type.toLowerCase()}/` : "/explore/projects/"
915
}
1016
}
1117

12-
await ScratchTools.waitForElement('li.link.explore > a');
13-
updateRedirect();
14-
15-
feature.options.addEventListener('changed', async ({ key, value }) => {
16-
if (key === 'customtab') {
17-
tabName = value;
18-
updateRedirect();
19-
}
20-
});
18+
feature.addEventListener("disabled", updateRedirects)
19+
feature.addEventListener("enabled", updateRedirects)
20+
feature.settings.addEventListener("changed", function({ value }) {
21+
type = value
22+
updateRedirects()
23+
})
2124
}

features/features.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"version": 2,
4-
"id": "custom-explore-redirect",
4+
"id": "custom-explore",
55
"versionAdded": "v3.10.0"
66
},
77
{

0 commit comments

Comments
 (0)