Greasy Fork

Greasy Fork is available in English.

龙空-图片显示

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

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

// ==UserScript==
// @name 龙空-图片显示
// @description 修复部分图片不能正常显示的问题
// @match *://lkong.cn/*
// @match *://www.lkong.net/thread*
// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @author eaudouce
// @grant none
// @version 0.0.1.20190819142014
// @namespace http://greasyfork.icu/users/329519
// ==/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;
      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);
    });
  };

  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);
    });
  }

})();