Code Monkey home page Code Monkey logo

Comments (2)

PascalKoe avatar PascalKoe commented on May 30, 2024 4

Ich hab mal bissle rumprobiert wie man das ganze eventuell halbwegs formatiert bekommen könnte.
Hoffentlich kann damit jemand mit der Idee was anfangen und das einbauen...
Zum probieren einfach Copy+Paste in die JS Console

// Irgendwie halt an den Inhalt kommen
let textElement = document.getElementsByClassName('clearfix')[0].firstChild;
let text = textElement.innerHTML;
textElement.innerHTML = '';

// Wenn eine leerzeile mit zwei Leerzeichen beginnt handelt es sich um den selben Absatz
let regex = /\n  /igm;
text = text.replace(regex, '');

// Jede Zeile ist jetzt ein Absatz oder eine Überschrift
let lines = text.split('\n');
for (let i = 0; i < lines.length; i++) {
	
  let node = null;
  // Kurz => Überschrift
  if (lines[i].length < 50) {
    node = document.createElement('h3');
  }
  else {
    // Lange Überschriften haben hoffentlich kein Satzzeichen/Symbol
    let lastChar = lines[i].charAt(lines[i].length - 1);
    if (lastChar == '.' ||
      	lastChar == '?' ||
      	lastChar == '!' ||
      	lastChar == '«' ||
        lastChar == ')'
    ) {
      node = document.createElement('p');
    }
    else {
      node = document.createElement('h3');
    }
  }
  
  // HTML nach Spiegel nachbasteln
  let wrapperDiv = document.createElement('div');
  wrapperDiv.className = 'RichText RichText--iconLinks RichText--lastPmb0 RichText--lastInline lg:w-8/12 md:w-10/12 lg:mx-auto md:mx-auto lg:px-24 md:px-24 sm:px-16 clearfix break-words word-wrap';
  let content = document.createTextNode(lines[i]);
  node.appendChild(content);
  wrapperDiv.appendChild(node);
  textElement.appendChild(wrapperDiv);
}

from bibbot.

juliankpf avatar juliankpf commented on May 30, 2024

So, ich hab mal alle Seiten durchgetestet. Vorab: nur beim Spiegel treten die Fehler auf (bei magazin.spiegel.de nicht)

noz.de lädt kein einziger Payed Artikel bei ca. 10 getesteten
berliner-zeitung.de laden bei mir ohne alles, finde ich nichts payed
handelsblatt.com / wiwo.de nicht getestet, weil Adblockerhinweis nicht auszuschalten ging (mein Fehler, nichts vom Addon)

from bibbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.