Skip to content

Commit 57f1b7f

Browse files
authored
Merge pull request #889 from MaterArc/custom-explore
Custom explore redirect
2 parents 2a88756 + 8e1080b commit 57f1b7f

File tree

5 files changed

+133
-21
lines changed

5 files changed

+133
-21
lines changed

extras/popup/popup.css

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,16 @@ 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;
477+
border: 1.5px solid var(--feature-input-bg);
478+
border-radius: .25rem;
479+
overflow: hidden;
474480
}
475481

476482
.option-selection span {
477-
border: 1.5px solid var(--feature-input-bg);
478483
padding: .25rem;
479484
padding-left: .5rem;
480485
padding-right: .5rem;
@@ -483,20 +488,24 @@ span.new-feature-tag.beta {
483488
background-color: transparent;
484489
color: var(--secondary-color);
485490
transition: background-color .3s, border .3s, color .3s;
491+
display: inline-block;
492+
word-break: break-word;
493+
white-space: nowrap;
494+
flex: 1 0 auto;
495+
text-align: center;
496+
border-inline-end: 1.5px solid var(--feature-input-bg);
497+
}
498+
499+
.option label {
500+
margin-right: 1rem;
486501
}
487502

488503
.option-selection span.option-selected {
489504
background-color: var(--theme);
490505
color: white;
491-
border: 1.5px solid var(--theme);
492-
}
493-
494-
.option-selection span:first-child {
495-
border-top-left-radius: .25rem;
496-
border-bottom-left-radius: .25rem;
506+
border-inline-end: 1.5px solid transparent;
497507
}
498508

499509
.option-selection span:last-child {
500-
border-top-right-radius: .25rem;
501-
border-bottom-right-radius: .25rem;
502-
}
510+
border-inline-end: none;
511+
}

extras/style.css

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,16 @@ body {
849849

850850
.option-selection {
851851
text-align: right;
852-
width: 100%;
852+
width: calc(100% - 1rem);
853+
display: flex;
854+
overflow-wrap: break-word;
855+
flex-wrap: wrap;
856+
border: 1.5px solid var(--feature-input-bg);
857+
border-radius: .25rem;
858+
overflow: hidden;
853859
}
854860

855861
.option-selection span {
856-
border: 1.5px solid var(--feature-input-bg);
857862
padding: .25rem;
858863
padding-left: .5rem;
859864
padding-right: .5rem;
@@ -862,20 +867,24 @@ body {
862867
background-color: transparent;
863868
color: var(--secondary-color);
864869
transition: background-color .3s, border .3s, color .3s;
870+
display: inline-block;
871+
word-break: break-word;
872+
white-space: nowrap;
873+
flex: 1 0 auto;
874+
text-align: center;
875+
border-inline-end: 1.5px solid var(--feature-input-bg);
876+
}
877+
878+
.option label {
879+
margin-right: 1rem;
865880
}
866881

867882
.option-selection span.option-selected {
868883
background-color: var(--theme);
869884
color: white;
870-
border: 1.5px solid var(--theme);
871-
}
872-
873-
.option-selection span:first-child {
874-
border-top-left-radius: .25rem;
875-
border-bottom-left-radius: .25rem;
885+
border-inline-end: 1.5px solid transparent;
876886
}
877887

878888
.option-selection span:last-child {
879-
border-top-right-radius: .25rem;
880-
border-bottom-right-radius: .25rem;
889+
border-inline-end: none;
881890
}

features/custom-explore/data.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"title": "Custom Explore Redirect",
3+
"description": "Automatically redirect to a specific tab on the Explore page.",
4+
"credits": [
5+
{
6+
"username": "ItsThatKittyDragon",
7+
"url": "https://scratch.mit.edu/users/ItsThatKittyDragon/"
8+
},
9+
{
10+
"username": "MaterArc",
11+
"url": "https://scratch.mit.edu/users/MaterArc/"
12+
},
13+
{
14+
"username": "rgantzos",
15+
"url": "https://scratch.mit.edu/users/rgantzos/"
16+
}
17+
],
18+
"type": [
19+
"Website"
20+
],
21+
"tags": [
22+
"New",
23+
"Featured"
24+
],
25+
"scripts": [
26+
{
27+
"file": "script.js",
28+
"runOn": "/*"
29+
}
30+
],
31+
"dynamic": true,
32+
"options": [
33+
{
34+
"id": "custom-explore-tab",
35+
"name": "Tab",
36+
"type": 4,
37+
"options": [
38+
{
39+
"name": "Animations",
40+
"value": "animations"
41+
},
42+
{
43+
"name": "Art",
44+
"value": "art"
45+
},
46+
{
47+
"name": "Games",
48+
"value": "games"
49+
},
50+
{
51+
"name": "Music",
52+
"value": "music"
53+
},
54+
{
55+
"name": "Stories",
56+
"value": "stories"
57+
},
58+
{
59+
"name": "Tutorials",
60+
"value": "tutorials"
61+
}
62+
]
63+
}
64+
]
65+
}

features/custom-explore/script.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default async function({ feature, console }) {
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+
})
11+
12+
function updateRedirects() {
13+
for (var i in ELEMENTS) {
14+
ELEMENTS[i].href = feature.self.enabled ? `/explore/projects/${type.toLowerCase()}/` : "/explore/projects/"
15+
}
16+
}
17+
18+
feature.addEventListener("disabled", updateRedirects)
19+
feature.addEventListener("enabled", updateRedirects)
20+
feature.settings.addEventListener("changed", function({ value }) {
21+
type = value
22+
updateRedirects()
23+
})
24+
}

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": "custom-explore",
5+
"versionAdded": "v4.0.0"
6+
},
27
{
38
"version": 2,
49
"id": "stage-in-spritepane",

0 commit comments

Comments
 (0)