海子铁路社区的部分老图片可能是升级调整过程中没有正确加载,写一个脚本正确加载

海子铁路社区的部分老图片,在当年为了节省服务器空间,迁移到了外部环境。后来更换了运维人员,同时外部环境到期了,于是就回迁。可能回迁之后,配置没有完全跟上,导致部分图片无法显示。现在也不知道运维人员还处理不。

反正我手头上还有当年留存的一些备份,那就正好撸一个脚本,替换到自己配置的网站路径上,实现图片的显示。

当年那些文件附件比较大,大概百十来G——当然在今天开来都是小菜,我这边的存档也需要一点一点慢慢解压缩。凑合来吧

以下是代码,会油猴的自己玩吧。看内容其实也知道了是要干啥的。😇

// ==UserScript==
// @name         hasea-img
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  display some old pics of hasea
// @author       CPStar
// @match        http://bbs.hasea.com/*
// @grant        unsafeWindow
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    $("img[src^='data/attachment/forum/lbupfile/']").each(function(){
        let $this = $(this);
        let src = $(this).attr("src");
        $this.attr("src", "http://hasea.cpstar.cn/lbupfile/" + src.substr(31,1) + "/" + src.substr(32,1) + "/" + src.substr(31));
    });

    $("img[file^='data/attachment/forum/lbupfile/']").each(function(){
        let $this = $(this);
        let src = $(this).attr("file");
        $this.attr("file", "http://hasea.cpstar.cn/lbupfile/" + src.substr(31,1) + "/" + src.substr(32,1) + "/" + src.substr(31));
    });

    $("img[src^='data/attachment/forum/forumid_']").each(function(){
        let $this = $(this);
        let src = $(this).attr("src");
        $this.attr("src", "http://hasea.cpstar.cn/forumid_" + src.substr(30));
    });

    $("img[file^='data/attachment/forum/forumid_']").each(function(){
        let $this = $(this);
        let src = $(this).attr("file");
        $this.attr("file", "http://hasea.cpstar.cn/forumid_" + src.substr(30));
    });

})();