You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/develop/userscripts/best-practices.md
-37Lines changed: 0 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,40 +162,3 @@ const newDeleteSprite = function (...args) {
162
162
};
163
163
```
164
164
{{< /admonition >}}
165
-
166
-
167
-
### Edge cases
168
-
169
-
170
-
#### Scratch project page and editor
171
-
172
-
173
-
##### The DOM is destroyed after going inside or outside the editor
174
-
175
-
Scratch creates all HTML elements each time the user clicks "see inside" or "see project page", and destroys the old ones.
176
-
This can usually be fixed by using `addon.tab.waitForElement` or the `urlChange` event.
177
-
178
-
##### The Scratch editor language can be changed without a reload
179
-
180
-
Unlike the Scratch website, the Scratch editor will not reload when changing the language. When selecting a different language, Scratch might destroy and re-create some HTML elements.
181
-
182
-
##### Other situations to consider
183
-
184
-
- The project editor may be used without a defined project ID (for example, when logged out).
185
-
- The editor might switch from LTR to RTL (or viceversa) without requiring a page reload.
186
-
187
-
188
-
#### Scratch website
189
-
190
-
##### scratch-www pages don't reload after logging in
191
-
192
-
Unlike scratchr2 pages, scratch-www pages do not force a page reload after logging in. For example, if you go to a project page while being logged out, then log in, the page will not reload. This also affects studios, the messages page, etc.
193
-
In contrast, all Scratch pages reload after logging out.
194
-
195
-
##### Project pages never return 404s
196
-
197
-
Even if the project is unshared or doesn't exist, Scratch returns a 200 HTTP status code. The "our server is Scratch'ing its head" message is added dynamically to the page by Scratch.
198
-
199
-
##### Other situations to consider
200
-
201
-
- Each of the 4 tabs inside studios have different URLs, but do not trigger a browser navigation. Addons that affect any of the 4 pages should run, no matter the initial URL.
Copy file name to clipboardExpand all lines: content/docs/develop/userscripts/debugging-userscripts.md
+41-2Lines changed: 41 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
---
2
2
title: Debugging userscripts
3
-
description: Tips to easily debug userscripts.
3
+
description: Tips to easily debug userscripts, and edge cases to consider.
4
4
---
5
5
6
-
Tips to easily debug userscripts.
6
+
Tips to easily debug userscripts, and edge cases to consider.
7
+
8
+
#### Tips
7
9
8
10
#### It's not always necessary to reload the extension
9
11
@@ -27,3 +29,40 @@ The `debugger;` keyword in JavaScript will freeze the page when ran, if the deve
27
29
#### Filter console messages by addon ID
28
30
29
31
Enter the addon ID on the "filter" console search bar to only view logs and warnings, as well errors logged with `console.error()`. Keep in mind that this will hide all exceptions, unless you're explicitly logging them in your code.
32
+
33
+
34
+
### Edge cases
35
+
36
+
37
+
#### Scratch project page and editor
38
+
39
+
40
+
##### The DOM is destroyed after going inside or outside the editor
41
+
42
+
Scratch creates all HTML elements each time the user clicks "see inside" or "see project page", and destroys the old ones.
43
+
This can usually be fixed by using `addon.tab.waitForElement` or the `urlChange` event.
44
+
45
+
##### The Scratch editor language can be changed without a reload
46
+
47
+
Unlike the Scratch website, the Scratch editor will not reload when changing the language. When selecting a different language, Scratch might destroy and re-create some HTML elements.
48
+
49
+
##### Other situations to consider
50
+
51
+
- The project editor may be used without a defined project ID (for example, when logged out).
52
+
- The editor might switch from LTR to RTL (or viceversa) without requiring a page reload.
53
+
54
+
55
+
#### Scratch website
56
+
57
+
##### scratch-www pages don't reload after logging in
58
+
59
+
Unlike scratchr2 pages, scratch-www pages do not force a page reload after logging in. For example, if you go to a project page while being logged out, then log in, the page will not reload. This also affects studios, the messages page, etc.
60
+
In contrast, all Scratch pages reload after logging out.
61
+
62
+
##### Project pages never return 404s
63
+
64
+
Even if the project is unshared or doesn't exist, Scratch returns a 200 HTTP status code. The "our server is Scratch'ing its head" message is added dynamically to the page by Scratch.
65
+
66
+
##### Other situations to consider
67
+
68
+
- Each of the 4 tabs inside studios have different URLs, but do not trigger a browser navigation. Addons that affect any of the 4 pages should run, no matter the initial URL.
0 commit comments