Greasy Fork is available in English.

添加按钮

添加指定按钮

  1. // ==UserScript==
  2. // @name 添加按钮
  3. // @namespace http://tampermonkey.net/
  4. // @author icewen
  5. // @description 添加指定按钮
  6. // @match *://baidu.com/*
  7. // @include https://www.baidu.com/*
  8. // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
  9. // @version 0.0.3
  10. // @grant none
  11. // ==/UserScript==
  12. ( function () {
  13. 'use strict' ;
  14. console.log('脚本运行~')
  15.  
  16. //与元数据块中的@grant值相对应,功能是生成一个style样式
  17. // GM_addStyle( '#down_video_btn{color:#fa7d3c;}' );
  18.  
  19. //视频下载按钮的html代码
  20. var btn_html = '<button id="test" style="{ marginLeft: 10px;color: blue; }">测试</button>';
  21.  
  22. //将以上拼接的html代码插入到网页里的ul标签中
  23. var parent = $('#s-top-left');
  24. if (parent) {
  25. parent.append(btn_html);
  26. }
  27.  
  28. var someTool = {
  29. };
  30.  
  31. $( function () {
  32. console.log('运行结束?')
  33. //执行下载按钮的单击事件并调用下载函数
  34. $( "#test" ).click( function () {
  35. alert('插入成功')
  36. });
  37. });
  38.  
  39. })();