Scaffold browser capture extension
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
body {
|
||||
min-width: 220px;
|
||||
margin: 0;
|
||||
font: 13px system-ui, sans-serif;
|
||||
background: #111827;
|
||||
color: #e5e7eb;
|
||||
}
|
||||
|
||||
main {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid #374151;
|
||||
border-radius: 4px;
|
||||
padding: 8px 10px;
|
||||
background: #1f2937;
|
||||
color: #f9fafb;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: #10b981;
|
||||
}
|
||||
|
||||
#status {
|
||||
min-height: 18px;
|
||||
margin: 0;
|
||||
color: #9ca3af;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<button id="capture-page">Send Page</button>
|
||||
<button id="capture-selection">Send Selection</button>
|
||||
<button id="retry">Retry Pending</button>
|
||||
<p id="status"></p>
|
||||
</main>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ext = typeof browser !== 'undefined' ? browser : chrome;
|
||||
var statusEl = document.getElementById('status');
|
||||
|
||||
function setStatus(text) {
|
||||
statusEl.textContent = text;
|
||||
}
|
||||
|
||||
function send(message) {
|
||||
setStatus('Sending...');
|
||||
Promise.resolve(ext.runtime.sendMessage(message)).then(function (result) {
|
||||
if (result && result.status === 'queued') setStatus('Queued until Verstak is available');
|
||||
else setStatus('Sent');
|
||||
}).catch(function (err) {
|
||||
setStatus(err && err.message ? err.message : String(err));
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('capture-page').addEventListener('click', function () {
|
||||
send({ type: 'verstak.capture', kind: 'page' });
|
||||
});
|
||||
|
||||
document.getElementById('capture-selection').addEventListener('click', function () {
|
||||
send({ type: 'verstak.capture', kind: 'selection' });
|
||||
});
|
||||
|
||||
document.getElementById('retry').addEventListener('click', function () {
|
||||
send({ type: 'verstak.capture', action: 'retryPending' });
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user