Skip to content

Commit 1a77b0b

Browse files
Move "edge cases" section to "debugging userscripts" page
1 parent e3d0e5c commit 1a77b0b

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

content/docs/develop/userscripts/best-practices.md

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -162,40 +162,3 @@ const newDeleteSprite = function (...args) {
162162
};
163163
```
164164
{{< /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.

content/docs/develop/userscripts/debugging-userscripts.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
title: Debugging userscripts
3-
description: Tips to easily debug userscripts.
3+
description: Tips to easily debug userscripts, and edge cases to consider.
44
---
55

6-
Tips to easily debug userscripts.
6+
Tips to easily debug userscripts, and edge cases to consider.
7+
8+
#### Tips
79

810
#### It's not always necessary to reload the extension
911

@@ -27,3 +29,40 @@ The `debugger;` keyword in JavaScript will freeze the page when ran, if the deve
2729
#### Filter console messages by addon ID
2830

2931
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

Comments
 (0)