2016-05-15 37 views
0

我知道如何在Html/Css,Javascript和jQuery中编程。如何将html元素添加到篡改密钥

虽然,我刚刚开始在Tampermonkey中编程,所以我不知道如何在Tampermonkey中实现html/css。脚本的目的是添加到一个已经存在的网站,我已经在网站上运行了,但是当我尝试自己做这件事时,什么都没有出现。我已经编写了UserScript部分并添加了jQuery UI。

对于初学者来说,我可以简单地了解如何做到这一点,我想简单地创建一个<div></div>元素并使用Css,只需简单地将其设置为页面上所有其他元素的可见框即可。

我不知道如何开始,但我想也许附加一个“div”到网站的body元素,但我不知道如何做到这一点,并操纵它。

回答

1

我有一个脚本运行SO,并添加一个按钮,这样

// ==UserScript== 
// @name   Fixed top menu + Inbox notification + Achievement notification 
// @author   LGSon (Fork of Cameron Bernhardt's (AstroCB) "Fixed Stack Exchange Top Bar") 
// @version  1.0 
// @description Fixed positioned top bar of Stack Exchange sites and notification in title bar 
// @match   *://*.stackoverflow.com/* 
// @exclude  *://api.stackexchange.com/* 
// @exclude  *://blog.stackexchange.com/* 
// @exclude  *://blog.stackoverflow.com/* 
// @exclude  *://chat.stackexchange.com/* 
// @exclude  *://chat.stackoverflow.com/* 
// @exclude  *://data.stackexchange.com/* 
// @exclude  *://elections.stackexchange.com/* 
// @exclude  *://stackexchange.com/* 
// @grant   GM_addStyle 
// ==/UserScript== 

var button = document.createElement("Button"); 
button.innerHTML = "Title"; 
button.style = "top:0;right:0;position:absolute;z-index:99999;padding:20px;"; 
document.body.appendChild(button);