Make script work for safari - #125
svalencia014 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to improve Safari compatibility and overall startup reliability for the WME URComments-Enhanced (URC-E) userscript by adding a fallback transport for Google Sheets requests and by improving error normalization/diagnostics.
Changes:
- Updated userscript metadata (version bump, switched WazeWrap
@requireURL to theupdate.greasyfork.orgendpoint). - Added
formatXhrErrorplus arequestWithReferrerFallbackwrapper that retries certain 403 “referer ” failures via page-contextfetch. - Adjusted initialization behavior to fail open for optional startup datasets (auto-switch and restrictions), and improved error display to include actionable “Details”.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (errMessage.includes('|')) { | ||
| const [reason, version] = errMessage.split('|'); | ||
| if ((reason === 'updateRequired') || (reason === 'spreadsheetUpdateRequired')) { | ||
| const scriptLink = createElem('a', { | ||
| href: _IS_BETA_VERSION ? dec(_BETA_DL_URL) : _PROD_DL_URL, target: '_blank', textContent: _IS_BETA_VERSION ? dec(_BETA_DL_URL) : _PROD_DL_URL |
There was a problem hiding this comment.
handleError now branches on errMessage.includes('|'), but only renders UI inside that branch when the prefix is updateRequired| or spreadsheetUpdateRequired|. Since newly introduced messages (e.g., formatXhrError uses | separators) can contain |, this can produce an empty error UI. Make the condition more specific (e.g., check startsWith('updateRequired|')/startsWith('spreadsheetUpdateRequired|')), or fall back to the generic error rendering when the split reason is unrecognized.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Do you have any ideas why the original code would fail only some of the time with Safari? |
Summary
This PR improves Safari compatibility and startup reliability for URC-E by fixing Google Sheets request failures, improving fallback behavior, and making error diagnostics actionable instead of generic.
Problem
On Safari, Google Sheets API calls were intermittently failing with 403 errors due to blocked requests from referer
<empty>.This caused:
What changed
Why this approach
User impact