Greasy Fork is available in English.

百度百科 图册图片查看无水印图片

去除百度百科图册中的图片水印,查看原图时目标链接也是无水印版本

  1. // ==UserScript==
  2. // @name 百度百科 图册图片查看无水印图片
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 去除百度百科图册中的图片水印,查看原图时目标链接也是无水印版本
  6. // @author Esgloamp
  7. // @match http*://baike.baidu.com/pic/*
  8. // @icon https://www.baidu.com/favicon.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. var targetElement = document.getElementById('imgPicture');
  17. targetElement.onload = function () {
  18. // imgPicture父节点
  19. let pictureDiv = document.getElementById('picture');
  20.  
  21.  
  22. // 当前有水印的图片
  23. let currImg = document.getElementById("imgPicture");
  24.  
  25. // 获取无水印图的url
  26. let noMarkUrl = currImg.getAttribute('src').split('?')[0];
  27.  
  28. // 右下角查看原图的目标链接也随着更改
  29. let srcImg = document.getElementsByClassName('tool-button origin');
  30. srcImg[0].setAttribute('href', noMarkUrl);
  31.  
  32. let noMarkImg = document.createElement('img');
  33. noMarkImg.setAttribute("id", "NoMarkImg");
  34. noMarkImg.setAttribute("src", noMarkUrl);
  35. noMarkImg.setAttribute("onload", "imageResize()")
  36. noMarkImg.setAttribute("style",
  37. `visibility: visible;
  38. position: absolute;
  39. display: inline-block;
  40. width: ${currImg.width}px;
  41. height: ${currImg.height}px;
  42. left: ${currImg.offsetLeft}px;
  43. top: ${currImg.offsetTop}px;
  44. margin-top: 1px;`);
  45. noMarkImg.setAttribute("url", noMarkUrl)
  46. pictureDiv.removeChild(pictureDiv.lastChild);
  47. pictureDiv.appendChild(noMarkImg);
  48. currImg.style.display = "none";
  49. console.debug("fucking imageResize finished");
  50.  
  51. };
  52. })();