Greasy Fork

APA Label - derstandard.at

10/02/2022, 13:08:42

目前为 2022-02-10 提交的版本。查看 最新版本

// ==UserScript==
// @name        APA Label - derstandard.at
// @namespace   Violentmonkey Scripts
// @match       https://www.derstandard.at/story/*
// @grant       none
// @version     1.0
// @author      oodeagleoo
// @license     MIT
// @description 10/02/2022, 13:08:42
// @require     https://cdn.jsdelivr.net/npm/@ryanmorr/[email protected]
// ==/UserScript==

function isApaArticle(article) {
  const paragraphs = article.querySelectorAll('p');
  for (const paragraph of paragraphs) {
    if (/APA,/.test(paragraph.innerText)) {
      return true;
    }
  }
  return false;
}

(async () => {
  waitFor = (selector) => new Promise((resolve) => ready(selector, resolve));

  const article = await waitFor('div.story article');  
  if (isApaArticle(article)) {
    const h1 = await waitFor('h1.article-title');
    h1.innerHTML = `<span style="color: #cb0000">APA: </span>${h1.innerText}`;
  }
  
})();