From 02ff8826c34d80bfc0d2c6035ce0215f7df2f297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Tue, 11 Dec 2018 11:31:38 +0800 Subject: [PATCH] Hotfix: jianshu img (#1259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复简书无法显示图片的问题 --- routes/jianshu/utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/routes/jianshu/utils.js b/routes/jianshu/utils.js index b9fa2dc3d..76e6a5158 100644 --- a/routes/jianshu/utils.js +++ b/routes/jianshu/utils.js @@ -17,6 +17,15 @@ async function load(link) { const serverOffset = date.getTimezoneOffset() / 60; const pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString(); + // 还原图片地址 + $('img').each((index, elem) => { + const $elem = $(elem); + const src = $elem.attr('data-original-src'); + if (src && src !== '') { + $elem.attr('src', `https:${src}`); + } + $elem.attr('referrerpolicy', 'no-referrer'); + }); // 提取内容 const description = $('.show-content-free').html();