Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IIFEs #452

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ext/js/accessibility/google-docs.js
Casheeew marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

(async () => {
/** */
async function main() {
// Reentrant check
// @ts-expect-error - Checking a property to the global object
if (self.googleDocsAccessibilitySetup) { return; }
Expand Down Expand Up @@ -71,4 +72,9 @@
script.textContent = `(${inject.toString()})();`;
parent.appendChild(script);
parent.removeChild(script);
})();
}

await main();

// Empty export to enable top level await
export {};
10 changes: 8 additions & 2 deletions ext/js/app/content-script-wrapper.js
Casheeew marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

(async () => {
/** */
Casheeew marked this conversation as resolved.
Show resolved Hide resolved
async function main() {
const src = chrome.runtime.getURL('js/app/content-script-main.js');
// eslint-disable-next-line no-unsanitized/method
await import(src);
})();
}

await main();

// Empty export to enable top-level await
export {};
11 changes: 8 additions & 3 deletions ext/js/yomitan.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import {CrossFrameAPI} from './comm/cross-frame-api.js';
import {EventDispatcher, deferPromise, invokeMessageHandler, log} from './core.js';
import {ExtensionError} from './core/extension-error.js';

// Set up chrome alias if it's not available (Edge Legacy)
if ((() => {
/**
* @returns {boolean}
*/
function checkChromeNotAvailable() {
let hasChrome = false;
let hasBrowser = false;
try {
Expand All @@ -36,7 +38,10 @@ if ((() => {
// NOP
}
return (hasBrowser && !hasChrome);
})()) {
}

// Set up chrome alias if it's not available (Edge Legacy)
if (checkChromeNotAvailable()) {
// @ts-expect-error - objects should have roughly the same interface
// eslint-disable-next-line no-global-assign
chrome = browser;
Expand Down