Hide solved griddlers

Hides solved griddlers and triddlers from search results

目前为 2015-03-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide solved griddlers
  3. // @namespace http://www.jenneth.com/greasemonkey/griddlers/hidesolved
  4. // @description Hides solved griddlers and triddlers from search results
  5. // @include http://www.griddlers.net/triddlers*
  6. // @include http://www.griddlers.net/griddlers*
  7. // @include http://griddlers.net/triddlers*
  8. // @include http://griddlers.net/griddlers*
  9. // @version 0.0.1.20150309014213
  10. // ==/UserScript==
  11.  
  12. run();
  13.  
  14. function run() {
  15. var puzzleList = getSearchResultRows();
  16. // GM_log("Found " + puzzleList.snapshotLength + " rows");
  17. cleanUpList(puzzleList);
  18. }
  19.  
  20. function getSearchResultRows() {
  21. var snapshot = document.evaluate("//tr[contains(@class,'journal-content-article')]",
  22. document.getElementById("column-2"), null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  23. return snapshot;
  24. }
  25.  
  26. function cleanUpList(snapshot) {
  27. var newRowNum = 0;
  28. for (var i=0; i<snapshot.snapshotLength; i++) {
  29. var row = snapshot.snapshotItem(i);
  30. if (cleanupRow(row, newRowNum)==1) {
  31. newRowNum++;
  32. }
  33. }
  34. }
  35.  
  36. function cleanupRow(row, rowNum) {
  37. var solvedtd = row.childNodes[row.childNodes.length - 2];
  38. var prettified = 0;
  39. if (solvedtd.textContent.length > 2) {
  40. // GM_log("Removing row containing " + solvedtd.textContent);
  41. remove(row);
  42. } else {
  43. // GM_log("Not removing row containing " + solvedtd.textContent);
  44. prettify(row, rowNum);
  45. prettified = 1;
  46. }
  47. return prettified;
  48. }
  49.  
  50. function remove(element) {
  51. element.parentNode.removeChild(element);
  52. }
  53.  
  54. function prettify(row, rownum) {
  55. if (rownum%2===0) {
  56. row.className = row.className.replace('section-alternate','section-body');
  57. } else {
  58. row.className = row.className.replace('section-body','section-alternate');
  59. }
  60. }