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.1
// @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');
    const iconStyles = 'position: relative; top: -0.1em; margin-right: 0.2em; padding: 2px 5px; font-size: 0.8em; color: var(--theme-background); background-color: #cb0000; border-radius: 0.3em;';
    h1.innerHTML = `<span style="${iconStyles}">APA</span>${h1.innerText}`;
  }
  
})();