2016-05-15 81 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);