PTT reformat for Evernote

原始的 PTT 網頁用 Evernote Web Clipper 擷取,圖片會跑版,此為替換原本的自動開圖區塊

当前为 2019-09-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name PTT reformat for Evernote
  3. // @namespace https://greasyfork.org/zh-TW/users/79288
  4. // @version 1.6
  5. // @description 原始的 PTT 網頁用 Evernote Web Clipper 擷取,圖片會跑版,此為替換原本的自動開圖區塊
  6. // @author jlhg
  7. // @match https://www.ptt.cc/bbs/*/*.html
  8. // @match https://www.ptt.cc/man/*.html
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let imageStyle = "max-height:none;max-width:800px";
  16.  
  17. ['.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.gif', '.GIF'].forEach(function(ext) {
  18. let images = document.querySelectorAll('a[href$="' + ext + '"]');
  19. for (let i = 0; i < images.length; i++) {
  20. let imageUrl = images[i].href;
  21. imageUrl = imageUrl.replace('https://i.imgur', 'http://i.imgur');
  22. imageUrl = imageUrl.replace('https://imgur', 'http://imgur');
  23. images[i].innerHTML += '<br><img src="' + imageUrl + '" style="'+ imageStyle + '"><br>';
  24. images[i].style.boxShadow = 'none';
  25. }
  26. });
  27.  
  28. let images = document.querySelectorAll('a[href^="https://imgur.com/"]');
  29. for (let i = 0; i < images.length; i++) {
  30. if (images[i].href.indexOf("https://imgur.com/a/") >= 0 || /\.(jpg|png)$/i.test(images[i].href)) {
  31. continue;
  32. }
  33.  
  34. images[i].innerHTML += '<br><img src="' + images[i].href.replace('https://imgur.com/', 'http://i.imgur.com/') + '.jpg" style="' + imageStyle + '"><br>';
  35. images[i].style.boxShadow = 'none';
  36. }
  37.  
  38. let richcontents = document.querySelectorAll('.richcontent');
  39. for (let i = 0; i < richcontents.length; i++) {
  40. richcontents[i].remove();
  41. }
  42. })();