Greasy Fork 还支持 简体中文。

PTT reformat for Evernote

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         PTT reformat for Evernote
// @namespace    https://greasyfork.org/zh-TW/users/79288
// @version      1.8
// @description  原始的 PTT 網頁用 Evernote Web Clipper 擷取,圖片會跑版,此為替換原本的自動開圖區塊
// @author       jlhg
// @match        https://www.ptt.cc/bbs/*/*.html
// @match        https://www.ptt.cc/man/*.html
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  let imageStyle = "max-height:none;max-width:800px";

  ['.jpg', '.JPG', '.png', '.PNG', '.jpeg', '.JPEG', '.gif', '.GIF'].forEach(function(ext) {
    let images = document.querySelectorAll('a[href$="' + ext + '"]');
    for (let i = 0; i < images.length; i++) {
      let imageUrl = images[i].href;
      images[i].innerHTML += '<br><img src="' + imageUrl + '" style="'+ imageStyle + '" referrerpolicy="no-referrer"><br>';
      images[i].style.boxShadow = 'none';
    }
  });

  let images = document.querySelectorAll('a[href^="https://imgur.com/"]');
  for (let i = 0; i < images.length; i++) {
    if (images[i].href.indexOf("https://imgur.com/a/") >= 0 || /\.(jpg|png)$/i.test(images[i].href)) {
      continue;
    }

    images[i].innerHTML += '<br><img src="' + images[i].href + '.jpg" style="' + imageStyle + '" referrerpolicy="no-referrer"><br>';
    images[i].style.boxShadow = 'none';
  }

  let richcontents = document.querySelectorAll('.richcontent');
  for (let i = 0; i < richcontents.length; i++) {
    richcontents[i].remove();
  }
})();