Greasy Fork is available in English.

百度百科 无水印图片查看

查看百科最新版本、历史版本无水印图片,历史图册页面进入的图片暂时不支持。

Version vom 27.03.2024. Aktuellste Version

  1. // ==UserScript==
  2. // @name 百度百科 无水印图片查看
  3. // @icon https://baidu.com/favicon.ico
  4. // @namespace https://greasyfork.org/zh-CN/users/20287-%E5%87%89%E5%A4%8F%E9%A3%8E%E6%AD%8C
  5. // @version 1.3.3.1
  6. // @description 查看百科最新版本、历史版本无水印图片,历史图册页面进入的图片暂时不支持。
  7. // @match http*://baike.baidu.com/picture/*
  8. // @match http*://baike.baidu.com/historypic/*
  9. // @match http*://baike.baidu.com/pic/*
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. // http*://baike.baidu.com/picview/history/* 似乎已经全部停用了
  14. (function(){
  15. let cssSelector = location.href.indexOf('history') > -1 ? '#imgPicture' : 'div[class^=imgWraper_]>img';
  16. let imgPicture = document.querySelector(cssSelector);
  17. //替换有水印的图片,替换“原图”中的链接
  18. const changeImg = ()=>{
  19. let imgId;
  20. if(window.location.href.indexOf('pic=') > -1){
  21. imgId=window.location.href.split('pic=')[1].split('?')[0];
  22. }else{
  23. imgId = location.href.split('/0/')[1].split('?')[0];
  24. }
  25. if(imgPicture.src !== 'https://bkimg.cdn.bcebos.com/pic/' + imgId){
  26. imgPicture.src='https://bkimg.cdn.bcebos.com/pic/' + imgId;
  27. imgPicture.url=imgPicture.src;
  28. }
  29. if(location.href.indexOf('history') > -1){
  30. let a = document.querySelector('.tool-button.origin');
  31. a.href = imgPicture.src;
  32. }
  33. };
  34. //首次进入需要运行一次,后续的为监测自动执行
  35. let interval = setInterval(()=>{
  36. imgPicture = document.querySelector(cssSelector);
  37. if (imgPicture && imgPicture.src.indexOf('\?') !== -1)
  38. {
  39. changeImg();
  40. clearInterval(interval);
  41. //启动检测: 修改动作 监测对象与配置
  42. new MutationObserver(changeImg).observe(imgPicture, {
  43. attributes: true,
  44. childList: false,
  45. attributeFilter: ["src"],
  46. subtree: false
  47. });
  48. }
  49. }, 100);
  50. })();