油猴 tamperMonkey 在百度首页 添加自己的自定义链接

发现 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; }');


})();
原文地址:https://www.cnblogs.com/pengchenggang/p/10641289.html