Ensure globals.js is loaded prior to execution of dependent scripts

This commit prevents a race condition that causes global variables
defined in globals.js to be inaccessible to the other content scripts
This commit is contained in:
Joseph Nahm
2024-04-08 22:20:57 -07:00
parent f2128e045b
commit c731c5316d
2 changed files with 51 additions and 47 deletions

View File

@@ -1,16 +1,26 @@
console.log('globals.js loaded');
if (typeof window.globalsLoaded === 'undefined') {
console.log('globals.js loaded');
let lastChecked = null;
window.globalsLoaded = true;
let Selectors = {
// Plus 用户的选择器
conversationsCheckbox: '.conversation-checkbox:checked',
deleteButton: '[class*="text-red"]',
confirmDeleteButton: 'button.btn.btn-danger',
threeDotButton: '[id^="radix-"]',
// 其他 Plus 用户选择器...
CONVERSATION_SELECTOR: 'div > div > div > div > div > div > nav > div > div > div > div > ol > li > div > a',
TITLE_SELECTOR: '.relative.grow.overflow-hidden.whitespace-nowrap',
};
let lastChecked = null;
let CHECKBOX_CLASS = 'conversation-checkbox';
let Selectors = {
// Plus 用户的选择器
conversationsCheckbox: '.conversation-checkbox:checked',
deleteButton: '[class*="text-red"]',
confirmDeleteButton: 'button.btn.btn-danger',
threeDotButton: '[id^="radix-"]',
// 其他 Plus 用户选择器...
CONVERSATION_SELECTOR: 'div > div > div > div > div > div > nav > div > div > div > div > ol > li > div > a',
TITLE_SELECTOR: '.relative.grow.overflow-hidden.whitespace-nowrap',
};
let CHECKBOX_CLASS = 'conversation-checkbox';
window.lastChecked = lastChecked;
window.Selectors = Selectors;
window.CHECKBOX_CLASS = CHECKBOX_CLASS;
} else {
console.log('globals.js already loaded, skipping re-initialization');
}