【问题标题】:Create Element Doesnt Show Up创建元素不显示
【发布时间】:2023-04-02 05:40:01
【问题描述】:

我正在尝试使用 html 菜单制作一个 Tampermonkey 脚本。下面是当前脚本,我尝试创建元素但它没有显示出来。所以我写了这个元素,它删除了页面上的所有其他内容。我尝试查看其他已回答的问题,但没有一个有帮助

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://mtsl.dk/csgo/
// @icon         https://www.google.com/s2/favicons?domain=freefrontend.com
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  var elem = document.createElement('div')
  elem.innerHTML = '<div id="menu"><style>div{background-color: #fec5bb; color: #3A7CA5; border: 0px solid red; border-radius: 5px; margin: 10px; padding: 5px;}</style> <div>Inventory Editor:<button>Edit Inventory</button></div><div>Autoclicker: <button>Auto Click</button></div></div>'
  document.write(elem.innerHTML)
})();
<!-- This is what elem.innerHTML looks like (see function above) -->

<!-- <div id="menu">
  <style>
    div {
      background-color: #fec5bb;
      color: #3A7CA5;
      border: 0px solid red;
      border-radius: 5px;
      margin: 10px;
      padding: 5px;
    }
  </style>
  <div>Inventory Editor:<button>Edit Inventory</button></div>
  <div>Autoclicker: <button>Auto Click</button></div>
</div> -->

【问题讨论】:

标签: javascript html tampermonkey userscripts


【解决方案1】:

尝试做:

overlay html

对于 css 的东西,你可以尝试这样做:

// @grant GM_addStyle

那就做吧

css

对不起,我不得不放链接,我没有足够的声誉来放实际图片。

【讨论】:

    猜你喜欢
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 2019-11-30
    • 2021-12-04
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多