hover for link

try to take over the world!

当前为 2017-02-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name hover for link
  3. // @namespace https://github.com/Khdoop
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author Khdoop
  7. // @match *://*/*
  8. // @grant none
  9. // @require https://code.jquery.com/jquery-3.1.1.min.js
  10. // ==/UserScript==
  11.  
  12.  
  13. var body = $(document.body);
  14. console.log('1111111', body);
  15. var anchors = body.find('a');
  16. var box = $('<div class="link-tooltip"></div>').appendTo(body);
  17.  
  18. box.css({
  19. display: 'block',
  20. position: 'absolute',
  21. left: 0,
  22. padding: '5px',
  23. 'font-size': '18px',
  24. background: 'white',
  25. border: '1px solid black',
  26. opacity: 0.9,
  27. 'word-break': 'break-all'
  28. });
  29.  
  30. anchors.on('mouseover', function() {
  31. box.css({display: 'block', top: body.scrollTop()}).text($(this)[0].href);
  32. }).on('mouseleave', function() {
  33. box.css({display: 'none'});
  34. });