downthemall/windows/popup.ts
2019-08-25 14:27:54 +02:00

31 lines
656 B
TypeScript

"use strict";
// License: MIT
import { localize } from "../lib/i18n";
declare let browser: any;
declare let chrome: any;
const runtime = browser !== "undefined" ? browser.runtime : chrome.runtime;
addEventListener("DOMContentLoaded", () => {
localize(document.documentElement);
document.body.addEventListener("click", e => {
let target = e.target as HTMLElement;
if (!target) {
return;
}
while (target) {
const {action} = target.dataset;
if (!action) {
target = target.parentElement as HTMLElement;
continue;
}
runtime.sendMessage(action);
close();
return;
}
});
});