-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
739b947
commit 7c7f96c
Showing
8 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function loadScript(path) { | ||
const s = document.createElement('script'); | ||
s.src = chrome.runtime.getURL(path); | ||
s.type = 'text/javascript'; | ||
s.onload = () => { | ||
s.remove(); | ||
}; | ||
(document.head || document.documentElement).appendChild(s); | ||
} | ||
|
||
// https://youmightnotneedjquery.com/#ready | ||
function ready(fn) { | ||
if (document.readyState !== 'loading') { | ||
fn(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', fn); | ||
} | ||
} | ||
|
||
ready(() => { | ||
const DB_PATH = 'static/db.json'; | ||
const CHARACTER_SHEET_CSS_PATH = 'src/css/sheet.css'; | ||
const ICON_PATH = 'static/icons/32.png'; | ||
loadScript('index.js'); | ||
fetch(chrome.runtime.getURL(DB_PATH)) | ||
.then((response) => response.json()) | ||
.then((db) => { | ||
const characterSheetCssURL = chrome.runtime.getURL( | ||
CHARACTER_SHEET_CSS_PATH, | ||
); | ||
const buttonIconURL = chrome.runtime.getURL(ICON_PATH); | ||
window.postMessage( | ||
{ type: 't20-data', db, characterSheetCssURL, buttonIconURL }, | ||
'*', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters