htmlToElements

Convert html source text to dom elements.

当前为 2020-08-29 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/410153/842388/htmlToElements.js

  1. // ==UserScript==
  2. // @name htmlToElements
  3. // @namespace https://github.com
  4. // @version 0.1
  5. // @description Convert html source text to dom elements.
  6. // @match *://*/*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. /**
  11. * https://stackoverflow.com/a/35385518
  12. * @param {String} HTML representing any number of sibling elements
  13. * @return {NodeList}
  14. */
  15. const htmlToElements = (htmlSrc) => {
  16. let template = document.createElement('template');
  17. template.innerHTML = htmlSrc;
  18. return template.content;
  19. };