油猴 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; }');


})();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM