Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Last active November 25, 2020 16:52
Show Gist options
  • Select an option

  • Save wolframkriesing/94e57a423c6758989282257b45055479 to your computer and use it in GitHub Desktop.

Select an option

Save wolframkriesing/94e57a423c6758989282257b45055479 to your computer and use it in GitHub Desktop.

Revisions

  1. wolframkriesing revised this gist Nov 25, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-news.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // What else? You can add or remove stop words that are used to find the articles
    // with the according words.

    const stopWords = ['corona', 'pandemie', 'trump', 'biden'];
    const stopWords = ['corona', 'covid', 'pandemie', 'trump', 'biden'];

    const cleanArticles = () => {
    const articles = document.querySelectorAll('article');
  2. wolframkriesing revised this gist Nov 25, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions clean-news.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    // Remove articles with certain stop words, on a website.
    //
    // How? This script can be pasted into the developer console of a browser.
    // When you run it (normally just by hitting ENTER) it blurs the according articles.
    //
    // What else? You can add or remove stop words that are used to find the articles
    // with the according words.

    const stopWords = ['corona', 'pandemie', 'trump', 'biden'];

    const cleanArticles = () => {
  3. wolframkriesing revised this gist Nov 25, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion clean-news.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ const cleanArticles = () => {
    });
    toRemove.forEach(a => a.style.opacity = .1); // make them less opaque
    //toRemove.forEach(a => a.remove); // remove them
    console.log(`cleaned ${toRemove.size()} articles`);
    console.log(`cleaned ${toRemove.size} articles`);
    };

    cleanArticles();
  4. wolframkriesing revised this gist Nov 25, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions clean-news.js
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@ const cleanArticles = () => {
    });
    toRemove.forEach(a => a.style.opacity = .1); // make them less opaque
    //toRemove.forEach(a => a.remove); // remove them
    console.log(`cleaned ${toRemove.size()} articles`);
    };

    cleanArticles();
  5. wolframkriesing created this gist Nov 25, 2020.
    17 changes: 17 additions & 0 deletions clean-news.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    const stopWords = ['corona', 'pandemie', 'trump', 'biden'];

    const cleanArticles = () => {
    const articles = document.querySelectorAll('article');
    const toRemove = new Set();
    articles.forEach(a => {
    stopWords.map(word => {
    if (a.textContent.toLowerCase().includes(word)) {
    toRemove.add(a);
    }
    });
    });
    toRemove.forEach(a => a.style.opacity = .1); // make them less opaque
    //toRemove.forEach(a => a.remove); // remove them
    };

    cleanArticles();