ao3 savior

Hide specified works on AO3

< Opinie na ao3 savior

Pytanie/komentarz

§
Napisano: 18-09-2018
Edytowano: 19-09-2018

Use of innerHTML disrupts other userscripts which use addEventListener

Hi, thank you for sharing this script, my fanfiction time is more enjoyable.

I made a userscirpt to manipulate tags via addEventListener. But my userscript didn't function properly at hided work by ao3 savivor. I searched solution and discovered this answer.

I edited getCut function to use appendChild instead innerHTML.

var getCut = function getCut(work) {
  var cut = document.createElement('div');

  cut.className = CSS_NAMESPACE + '-cut';
  //cut.innerHTML = work.innerHTML
  Array.from(work.childNodes).forEach(function(child) {
    cut.appendChild(child)
  });

  return cut;
};

I appreciate if you could include this in next update, provided changed code doesn't produce unexpected errors.

Thanks.

tuffAutor
§
Napisano: 27-09-2018

That's done with 1.12 - thanks for the snippet!

§
Napisano: 27-09-2018

If you want to change only words in visible text, and not in the tags and attributes, do not use .innerHTML. Use another method. This script has an example of changing certain displayed words: https://greasyfork.org/en/scripts/23624-profanity-filter.

Odpowiedz

Zaloguj się, by odpowiedzieć.