Hide TopCoder problem archive categories

Hides the category list in the topcoder problem archive, because knowing the categories of a problem can spoil the solution! (The categories are replaced with '...', click on them to toggle hidden-ness.)

目前為 2015-06-20 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Hide TopCoder problem archive categories
  3. // @namespace kunaifirestuff
  4. // @description Hides the category list in the topcoder problem archive, because knowing the categories of a problem can spoil the solution! (The categories are replaced with '...', click on them to toggle hidden-ness.)
  5. // @include http://community.topcoder.com/tc?module=ProblemArchive*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var table = document.getElementsByTagName('b') [0].parentElement.parentElement.parentElement.parentElement;
  11. var categoryArray = new Array(table.childElementCount - 9);
  12. var hiddenText = '...';
  13.  
  14. for (var i = 3; i < table.childElementCount - 6; i++) {
  15. (function (i) {
  16. var cats = table.children[i].children[5];
  17. categoryArray[i - 3] = cats.textContent;
  18. cats.textContent = hiddenText;
  19. cats.setAttribute('align', 'center');
  20. cats.addEventListener('click', function () {
  21. if (cats.textContent == hiddenText) {
  22. cats.textContent = categoryArray[i - 3];
  23. } else {
  24. cats.textContent = hiddenText;
  25. }
  26. });
  27. }(i));
  28. }