PDAWiki: 正常质量的图片.

修复 PDAWiki 模糊的图片。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @namespace   [email protected]
// @version     1.0.2.20180607
// @grant       unsafeWindow
// @include     /^https?://(www\.)?pdawiki\.com/
// @match       https://www.pdawiki.com/forum/forum.php?mod=viewthread&tid=13941
// @match       http://www.pdawiki.com/forum/forum.php?mod=viewthread&tid=13941
// @run-at      document-start
// @name        PDAWiki: Normal quality images.
// @name:zh-CN  PDAWiki: 正常质量的图片.
// @name:zh-TW  PDAWiki: 正常质量的图片.
// @description Fix PDAWiki blurred images.
// @description:zh-CN 修复 PDAWiki 模糊的图片。
// @description:zh-TW 修复 PDAWiki 模糊的图片。
// ==/UserScript==
function _editSrc(element){
 
      var _src = element.getAttribute('src');
      if (/nothumb=yes/i.test(_src)) return;
      if (!(/^forum\.php/i.test(_src))) return;
      
      var _width = element.width;
      var _height = element.height;
  
      element.setAttribute('src', _src + "&nothumb=yes");
      element.removeAttribute('height');
      element.removeAttribute('width');
      console.log(`w:${_width} h:${_height}`);
      if ((_width === undefined)||(_height === undefined)|| (_width * 1.4 < _height)){
        element.setAttribute('style', 'max-width:80%;');
      } else {
        element.setAttribute('style', 'max-width:600px;');
      }
}

  var style = document.createElement('style');
  style.textContent = '.jammer, .fn_wx_fixed, .pct center, #floatPanel {' + [
    'display: none !important'
  ].join(';') + '}';
  document.head.appendChild(style);
document.addEventListener('DOMContentLoaded', function () {
  console.log('PDA loaded');
  //console.log('select:' + document.querySelector('img.zoom'));
  
  var _href = window.location.href;
  if (!(/\bviewthread\b|\bthread\b/i.test(_href))) return;
  
  var imgs = document.querySelectorAll('img.zoom');
  console.log('----- imgs:' + imgs.length);
  
  for (var item of imgs){
    var _src = item.getAttribute('src');
    console.log('-- src:' + _src);
  
    //item.removeAttribute('lazyloaded');
    if (/^forum\.php/i.test(_src)){
      _editSrc(item);
    } else {
      item.addEventListener('load', function(){
        _editSrc(this);
      })
    }
    //console.log(item);
  
  }
  
}, true);


/*
setTimeout(function(){
  var imgs = document.querySelectorAll('img.zoom');
  console.log('imgs:' + imgs.length);
  for (var item of imgs){
    console.log('Loop');
    console.log(item);
  }
}, 0);
*/