Miniflux detect deleted bluesky posts

Makes the External Link unclickable if the bsky post was deleted because opening a deleted post is a waste of time.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Miniflux detect deleted bluesky posts
// @namespace    https://reader.miniflux.app/
// @version      5
// @description  Makes the External Link unclickable if the bsky post was deleted because opening a deleted post is a waste of time.
// @author       Tehhund
// @match        *://*.miniflux.app/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=miniflux.app
// @run-at       document-end
// @grant        GM.xmlHttpRequest
// @license      MIT
// ==/UserScript==

/* jshint esversion: 8 */

const detect = async () => {
  if (window.location.href.includes(`/entry/`)) { // Only run when viewing a single entry. If this runs when viewing a list of entries it slams bsky with too many requests and triggers HTTP 429 errors.
    const links = [...document.getElementsByTagName(`a`)];
    for (const link of links) {
      if (link.href.includes(`bsky.app`) && link.getAttribute(`data-original-link`) === `true`) {
        const url = link.href;
        console.log(url);
        GM.xmlHttpRequest({
          method: "GET",
          url: url,
          headers: {
            "User-Agent": "Mozilla/5.0",
            "Accept": "text/xml"
          },
          onload: function (response) {
            console.log(response.responseText);
            if (response.responseText.includes`<title>Bluesky</title>`) { // This exact text only appears on deleted posts. Live posts have the user's handle here.
              const newSpan = document.createElement(`span`);
              newSpan.textContent = `No ${link.textContent}`;
              link.insertAdjacentElement(`beforebegin`, newSpan);
              link.remove();
            }
          }
        });
      }
    }
  }
}

detect();