📜  注入样式表删除 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:07.160000             🧑  作者: Mango

代码示例1
/* Answer to: "injected stylesheet remove" */

function loadCSS(file) {
  var link = document.createElement("link");
  link.href = chrome.extension.getURL(file + '.css');
  link.id = file;
  link.type = "text/css";
  link.rel = "stylesheet";
  document.getElementsByTagName("head")[0].appendChild(link);
}

function unloadCSS(file) {
  var cssNode = document.getElementById(file);
  cssNode && cssNode.parentNode.removeChild(cssNode);
}