Bedre Tabloid

Undgå clickbait. Lader dig se links inden du klikker, og fjerner uønskede elementer som reklamer og betalingsartikler. Tilpasset BT, Ekstra Bladet, Se og Hør, Billed Bladet og TV2 Nyhederne. Juster selv stopordene i koden for at tilpasse filtreringen til dine præferencer.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bedre Tabloid
// @namespace    greasyshark
// @version      1.3
// @description  Undgå clickbait. Lader dig se links inden du klikker, og fjerner uønskede elementer som reklamer og betalingsartikler. Tilpasset BT, Ekstra Bladet, Se og Hør, Billed Bladet og TV2 Nyhederne. Juster selv stopordene i koden for at tilpasse filtreringen til dine præferencer.
// @author       Greasy Shark
// @match        https://www.bt.dk/*
// @match        https://www.seoghoer.dk/*
// @match        https://ekstrabladet.dk/*
// @match        https://www.billedbladet.dk/*
// @match        https://tv2.dk/*
// @match        https://nyheder.tv2.dk/*
// @require      https://code.jquery.com/jquery-3.5.1.min.js
// @grant        GM_addStyle
// @license      GNU GPLv3

// ==/UserScript==

const delay = t => new Promise(resolve => setTimeout(resolve, t));

GM_addStyle(`
   .showlinks {
      padding: 10px 10px 10px 0;
      font-size: 1.3rem;
      display: block;
      color: inherit;
      text-decoration: none;
      font-family: sans-serif;
      font-weight: bold;
   }
  @media (max-width: 769px) {
    .theme-ekstrabladet-v2 .dre-item--sm-half {width: 100%; flex:none; }
  }

  div[data-component='ModalConsentWall'] { display: none }

  .PostConsentModal_modal__Gg8wX,.PostConsentModal_modal__TPXf4, article.dre-item--feature-e-commerce, article.dre-item--feature-plus { display: none !important }
`)

/* globals $ */
// Fjern reklamer og betalingsartikler
let ignoreList = "click,network,direct,selected,performance";

//Fjern udkommenteringen herunder hvis du ikke gider læse om sport
ignoreList = ignoreList + "," + "betting,sport,fodbold,transfervinduet,golf,superliga,haa?ndbold,tennis,ishockey,formel-1,oevrig-sport,cykling,tour-de-france,badminton,vinter-ol|atletik"

//Fjern udkommenteringen herunder hvis du ikke gider læse om kendte og kongelige mv.
//ignoreList = ignoreList + "," + "royale,kendte"

// Tilføj evt selv stopord til ovennævnte lister

const re = new RegExp(ignoreList.replace(/,/g, "|"), "i");

const processBtTeasers = function() {
   if (!location.href.match(/(^|\.)bt\.dk/)) return;

   document.querySelectorAll('div[data-item-id^="urn:bm:article:"]').forEach(card => {
      if (card.dataset.showlinksProcessed) return;
      card.dataset.showlinksProcessed = '1';

      if (card.querySelector('[class*="AdvertorialLabel"], [class*="ArticleSponsoredLabel"]')) {
         card.style.display = 'none';
         return;
      }

      const a = card.querySelector('a[class*="TeaserLink_link"]');
      if (!a) return;
      const href = (a.getAttribute('href') || '').split('?')[0];
      if (!href) return;
      const link = href.replace(/^https?:\/\/[^\/]+\//, '');

      if (link.match(re)) {
         card.style.display = 'none';
         return;
      }

      const showlinks = document.createElement('a');
      showlinks.className = 'showlinks';
      showlinks.href = href;
      showlinks.textContent = link;

      const target = card.querySelector('[class*="_relatedLinks"]')
                  || card.querySelector('[class*="_textContent"]')
                  || card;
      target.appendChild(showlinks);
   });
};

const replaceVideosWithPosters = function() {

   const containers = document.querySelectorAll('.tc_video__video');

   containers.forEach(container => {

      const video = container.querySelector('video');
      if (!video) return;

      const style = window.getComputedStyle(container);
      const posterVar = style.getPropertyValue('--poster').trim();

      const imageUrl = posterVar.replace(/^url\(["']?/, '').replace(/["']?\)$/, '');

      if (imageUrl && imageUrl !== 'none') {
         const img = document.createElement('img');
         img.src = imageUrl;

         img.style.width = '100%';
         img.style.height = '100%';
         img.style.objectFit = 'cover';
         img.style.display = 'block';

         video.remove();
         container.appendChild(img);
      }
   });
}

const observer = new MutationObserver((mutations) => {
   replaceVideosWithPosters();
   processBtTeasers();
});

observer.observe(document.body, {
   childList: true,
   subtree: true
});

(async function() {

   $("a[data-trackname='plus_arkiv_rodgulsort'").hide()
   $(".dre-item__pretitle:contains('Annoncørbetalt')").parents("article").hide()
   $(".premium-dogear").parents("a").hide()
   $(".Softwall__skip").click()

   processBtTeasers();

   $("article.dre-item, article.teaser").each((i,e) => {
      let href = $("a:first",e).attr("href").split("?")[0]
      let link = href.replace(/https?:\/\/[^\/]+\//, "")
      if(link.match(re)) {
         $(e).hide()
      }
      else {
         if(location.href.match("seoghoer.dk")) {
            $(e).after(`<a href="${href}">${link}</a>`)
         }
         else if(location.href.match("ekstrabladet.dk")) {
            $("div[class^=dre-item__alt-title--]:visible", e).after(`<a class="showlinks" href="${href}">${link}</a>`)
         }
         else {
            $(e).append(`<a class="showlinks" href="${href}">${link}</a>`)
         }
      }
   });

   // BT
   await delay(1000)
   $("article > a[href*='shoppingtips-med-reklamelinks']").parent("article").hide()

})();