Add debug log to insert / remove element
This commit is contained in:
parent
bd948616cd
commit
8015eacce7
|
@ -2,6 +2,9 @@ import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import browser from "webextension-polyfill";
|
import browser from "webextension-polyfill";
|
||||||
import TranslateContainer from "./components/TranslateContainer";
|
import TranslateContainer from "./components/TranslateContainer";
|
||||||
|
import log from "loglevel";
|
||||||
|
|
||||||
|
const logDir = "constent/index";
|
||||||
|
|
||||||
let isEnabled = true;
|
let isEnabled = true;
|
||||||
const handleMessage = async request => {
|
const handleMessage = async request => {
|
||||||
|
@ -29,6 +32,7 @@ browser.runtime.onMessage.addListener(handleMessage);
|
||||||
const removeElement = () => {
|
const removeElement = () => {
|
||||||
const element = document.getElementById("simple-translate");
|
const element = document.getElementById("simple-translate");
|
||||||
if (!element) return;
|
if (!element) return;
|
||||||
|
log.log(logDir, "removeElement()");
|
||||||
|
|
||||||
ReactDOM.unmountComponentAtNode(element);
|
ReactDOM.unmountComponentAtNode(element);
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.removeChild(element);
|
||||||
|
@ -39,6 +43,7 @@ let isFirst = true;
|
||||||
const insertElement = () => {
|
const insertElement = () => {
|
||||||
const element = document.getElementById("simple-translate");
|
const element = document.getElementById("simple-translate");
|
||||||
if (element) return;
|
if (element) return;
|
||||||
|
log.log(logDir, "insertElement()");
|
||||||
|
|
||||||
document.body.insertAdjacentHTML("beforeend", "<div id='simple-translate'></div>");
|
document.body.insertAdjacentHTML("beforeend", "<div id='simple-translate'></div>");
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
|
|
Loading…
Reference in a new issue