發現 GM_addStyle 函數不能用了,從寫加載css函數。 剩下找個定位 添加內容 就很簡單了。
// ==UserScript== // @name helloWorld // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://www.baidu.com/ // @grant none // @require http://code.jquery.com/jquery-1.11.0.min.js // ==/UserScript== $(document).ready(function(){ // 在這里寫你的代碼... // console.info('form',$("form")) let m = `<div style="color:#fff;position: absolute;bottom: -30px;"> <a class="myLink" href="http://www.baidu.com/" target="_blank">aaa</a> </div>` $(m).appendTo("#s_form_wrapper") }); (function() { 'use strict'; // Your code here... function addGlobalStyle(css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } addGlobalStyle('a.myLink, a.myLink:hover { color:#fff; }'); })();