storage.sync rejects any item over 8192 bytes, and the options page writes every field in one set(). An oversized template therefore made every later save fail, including changes to unrelated settings, with only a brief "Could not save settings". Cap the template at 1,000 UTF-16 units: maxlength on the input, and mergeSettings falls back to the default for a longer stored value, as it does for other out-of-range settings. Even a template of pasted control characters (six bytes each once JSON-escaped) stays under the quota; a test pins that arithmetic and another ties the HTML maxlength to the constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
825 B
JavaScript
22 lines
825 B
JavaScript
// Single source of truth for the settings shape and their defaults.
|
|
// Defaults reproduce the extension's pre-1.1 behaviour exactly: both URL toggles off mean the only URL parameter sent is `q`.
|
|
|
|
export const OPEN_IN_VALUES = ["new-tab", "background-tab", "new-window"];
|
|
|
|
// In UTF-16 units, as maxlength counts. Keeps the template far inside
|
|
// storage.sync's 8192-byte item quota even when every character is a pasted
|
|
// control character (six bytes once JSON-escaped), and far beyond any template
|
|
// the 8,000-character URL budget could send.
|
|
export const MAX_TEMPLATE_CHARS = 1000;
|
|
|
|
export const DEFAULT_SETTINGS = {
|
|
contextMenuMode: "simple",
|
|
showTranslate: false,
|
|
translationMode: "ask",
|
|
translationLanguage: "",
|
|
temporaryChat: false,
|
|
webSearch: false,
|
|
openIn: "new-tab",
|
|
promptTemplate: "{query}",
|
|
};
|