Comment Is Hidden

当前为 2016-04-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Comment Is Hidden
  3. // @description:en Remove the Coment Is Free articles (and the whole Opinion section) from the Guardian's front page.
  4. // @namespace www.ballpointbanana.com
  5. // @include http://www.theguardian.com/uk
  6. // @version 1
  7. // ==/UserScript==
  8.  
  9. // Find the Opinion subsection.
  10. var opinion = document.querySelector("section#opinion");
  11. opinion.style = "display:none;"
  12.  
  13. // Find all the "items" on the Guardian.
  14. var items = document.querySelectorAll("div.fc-item__container");
  15.  
  16. // Spin through them and hide all the divs containing a link to commentisfree.
  17. for (var ii = 0; ii < items.length; ii++) {
  18. var thisdiv = items[ii];
  19. if (thisdiv.querySelector("a").href.indexOf("commentisfree") != -1) {
  20. thisdiv.style = "display: none;"
  21. }
  22. }