龙空-图片显示

修复部分图片不能正常显示的问题

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        龙空-图片显示
// @description 修复部分图片不能正常显示的问题
// @namespace   https://greasyfork.org/users/329519
// @version     0.1.1
// @match       *://lkong.cn/*
// @match       *://www.lkong.net/thread*
// @require     https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @author      eaudouce
// @grant       none
// ==/UserScript==
(function() {
  'use strict';
  //console.log('start '+location.href);
  var href=location.href, timer;

  var loadImg = function(){
    //console.log('reload image');
    var imgs=href.indexOf('.cn')>0?$('.inthread img'):$('.t_f img'), str;
    //imgs.attr('referrerpolicy','no-referrer');

    imgs.each(function(i,value){
      //console.log(value.src);
      if(value.src.indexOf('lkong.cn') > 0) return;
      // 路过图床图片链接,非图片真实地址
      if(value.src.indexOf('imgchr.com/i/') > 0) {
        $(this).attr('href', value.src).attr('src', '//s2.ax1x.com/2019/09/25/uZ22xH.jpg').attr('alt','点击看图');
        $(this).on('click', function(){
          window.open($(this).attr('href'));
        });
        return;
      }
      // 新浪图床
      str = value.src.replace(/ws(\d+)\.sinaimg\.cn/i, 'ww$1.sinaimg.cn').replace('https:','');
      //console.log(str);
      $(this).attr('referrerpolicy','no-referrer').attr('src',str);
    });
  };

  var imgchr = function(e){
    var t=e.target||e.srcElement;
    console.log($(t.document));
  };

  if(href.indexOf('.net') > 0) {
    loadImg();
  } else {
    if(href.indexOf('thread') > 0) {
      $('#lkong_content').bind('DOMNodeInserted', function(e){
        console.log('change #lkong_content');
        if(timer) clearTimeout(timer);
        timer = setTimeout(loadImg, 500);
      });
    }
    $('#lkong_pane').bind('DOMNodeInserted', function(e){
      //console.log('change #lkong_pane');
      if(timer) clearTimeout(timer);
      timer = setTimeout(loadImg, 500);
    });
  }

})();