Skip to content

Commit 3559cd3

Browse files
committed
Use insertCss API over manually injecting via JS
1 parent 61b10ca commit 3559cd3

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

js/background.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
66

77
// Setup page for layout changes and show page action
88
if (match) {
9+
chrome.tabs.insertCSS(null, {
10+
file: 'css/layout.css'
11+
});
912
chrome.tabs.executeScript(null, {
1013
file: 'js/init.js'
1114
});

js/init.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
function insertCss() {
2-
const cssFile = chrome.extension.getURL('css/layout.css');
3-
const cssId = 'layoutcss';
4-
5-
if (document.getElementById(cssId) === null) {
6-
let css = document.createElement('link');
7-
css.id = cssId;
8-
css.type = 'text/css';
9-
css.rel = 'stylesheet';
10-
css.href = cssFile;
11-
document.getElementsByTagName('head')[0].appendChild(css);
12-
}
13-
}
14-
151
function syncState() {
162
chrome.storage.sync.get('classList', function(result) {
173
let board = document.getElementById('board');
@@ -45,5 +31,4 @@ function toggleLayout() {
4531
}
4632
}
4733

48-
insertCss();
4934
syncState();

manifest.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
"storage",
2020
"webNavigation"
2121
],
22-
"web_accessible_resources": [
23-
"css/layout.css"
24-
],
2522
"page_action": {
2623
"default_title": "List Layouts for Trello"
2724
},

0 commit comments

Comments
 (0)