Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
Force reader view in browser / Modify the content of all a tags in JS

first time posting on here. Let me preface this by saying that I am not that well versed in JS yet. I am trying to write a simple JavaScript script that forces reader view for clear viewing of a linked webpage (DOM manipulation). I was looking online for a good way to do this, and at first I thought Node.insertBefore() would be a good way, but I came to realize that this would create a new node instead of modifying the existing one, so I came to Stackoverflow to try and find a good way of doing this but I could not find a satisfying answer.

The way I want to go about it is modifying all a elements in the document to have 'about:reader?url=' before the URL, and after that is working, a check to see what browser the user is using, and modify the code to ensure the code is compatible with the users browser. Only here I found out that Chrome users require the manual enabling of an experimental flag, which will likely cause some trouble.

My code looks like this:

HTML:

<body>
    <div id="parentElement">
    <a href="stackoverflow.com/questions">Click here</a>
</div>

    <script src="js\script.js"></script>
</body>

JS:

var readerText = document.createTextNode('about:reader?url=');
var link = document.getElementsByTagName('a');

link.parentNode.insertBefore(readerText, link);


// Get the parent element
let parentElement = document.getElementById('parentElement')
// Get the parent's first child
let theFirstChild = parentElement.firstChild

// Create a new element
let newElement = document.createElement("div")

// Insert the new element before the first child
parentElement.insertBefore(newElement, theFirstChild)

Any help would be greatly appreciated, not only are code suggestions welcome, but also any knowledge about how different browsers approach reader view and if there is a feasible way to consistently force reader view in different browsers. Thank you! -Seraphym

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda