Use msg more in documentation code snippets
For example, https://scratchaddons.com/docs/develop/userscripts/best-practices/ has the following code snippet:
// Do this instead:
document.querySelector(".remix-button").addEventListener("click", () => {
prompt("Are you sure you want to remix?");
});
Which probably should be something like:
// Do this instead:
document.querySelector(".remix-button").addEventListener("click", () => {
prompt(msg("remix-confirm"));
});
That specific example is about XSS, so using msg() there can make it confusing. It becomes more complicated to explain because safeMsg would also be worth mentioning. Also, the reader might incorrectly interpret that msg() avoids XSS, instead of el.textContent.
I guess we could add a code comment such as: // Note: real userscript code should use msg() here
That specific example is about XSS, so using
msg()there can make it confusing. It becomes more complicated to explain becausesafeMsgwould also be worth mentioning. Also, the reader might incorrectly interpret thatmsg()avoids XSS, instead ofel.textContent.I guess we could add a code comment such as:
// Note: real userscript code should use msg() here
True, that specific example was poorly chosen, I'll replace it with another one.
I believe we should keep the current examples, but we could add a comment such as // Note: real userscript code should use msg() here next to the lines that use hardcoded strings.