-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
83 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
.ext-app { | ||
width: 250px; | ||
max-width: 100%; | ||
font: 14px/1.15 BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; | ||
user-select: none; | ||
} | ||
|
||
.ext-list { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.ext-list__item { | ||
width: 100%; | ||
padding: 3px; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
cursor: pointer; | ||
} | ||
|
||
.ext-list__item--active { | ||
color: lightgreen; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,56 @@ | ||
|
||
; (function () { | ||
|
||
|
||
let app = null; | ||
let extIds = []; | ||
|
||
function init() { | ||
getExtensions(); | ||
|
||
app = document.getElementById('ext-app'); | ||
|
||
app.addEventListener('click', toggleExtension); | ||
app.onmousedown = () => false; | ||
} | ||
|
||
function getExtensions() { | ||
chrome.management.getAll(render); | ||
} | ||
|
||
function render(extensions) { | ||
extensions = extensions || []; | ||
extensions = extensions.filter((item) => !item.isApp); | ||
|
||
if (!extensions.length) return; | ||
|
||
app.appendChild(buildList(extensions)); | ||
} | ||
|
||
function buildList(extensions) { | ||
let list = document.createElement('ul'); | ||
list.className = 'ext-list'; | ||
|
||
extensions.forEach((item) => { | ||
let listItem = document.createElement('li'); | ||
|
||
listItem.textContent = item.name; | ||
listItem.dataset.id = item.id; | ||
listItem.className = 'ext-list__item'; | ||
|
||
list.appendChild(listItem); | ||
}); | ||
|
||
return list; | ||
} | ||
|
||
function toggleExtension(event) { | ||
const item = event.target; | ||
|
||
if (!item.closest('.ext-list__item')) return; | ||
|
||
item.classList.toggle('ext-list__item--active'); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', init); | ||
|
||
})(); |
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
</head> | ||
|
||
<body> | ||
<div id="ex-app"></div> | ||
<div id="ext-app" class="ext-app"></div> | ||
</body> | ||
|
||
</html> |