Greasy Fork script list beautifier

Reformat script list on greasyfork.org

目前为 2014-07-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork script list beautifier
  3. // @namespace http://websocket.bplaced.net
  4. // @version 1.0.1
  5. // @description Reformat script list on greasyfork.org
  6. // @match https://greasyfork.org/users/*
  7. // @match https://greasyfork.org/scripts*
  8. // @copyright 2014, Thomas Theiner
  9. // ==/UserScript==
  10.  
  11. window.addEventListener('load', function() {
  12. if(unsafeWindow.jQuery) {
  13. $ = unsafeWindow.jQuery;
  14. $('section .script-list, body > .script-list').each(function() {
  15. $table = $('<table border="0" width="100%"></table>');
  16. $tbody = $('<tbody></tbody>');
  17. $thead = $('<thead></thead>');
  18. $theadtr = $('<tr></tr>');
  19. $th = $('<td style="font-weight: bold" width="60%"></td>');
  20. $th.html('Title');
  21. $theadtr.append($th);
  22. $th = $('<td style="font-weight: bold" width="8%"></td>');
  23. $th.html('Author');
  24. $theadtr.append($th);
  25. $th = $('<td style="font-weight: bold" width="8%"></td>');
  26. $th.html('Daily');
  27. $theadtr.append($th);
  28. $th = $('<td style="font-weight: bold" width="8%"></td>');
  29. $th.html('Total');
  30. $theadtr.append($th);
  31. $th = $('<td style="font-weight: bold" width="8%"></td>');
  32. $th.html('Created');
  33. $theadtr.append($th);
  34. $th = $('<td style="font-weight: bold" width="8%"></td>');
  35. $th.html('Updated');
  36. $theadtr.append($th);
  37. $tbody.append($theadtr);
  38. $(this).find('li').each(function() {
  39. var $scriptlink = $(this).find('article h2 a');
  40. var $scriptdesc = $(this).find('article h2 .description');
  41. $tr = $('<tr></tr>');
  42. $td = $('<td></td>');
  43. $td.append($scriptlink);
  44. $td.append('<br/>');
  45. $td.append($scriptdesc);
  46. $tr.append($td);
  47. $(this).find('article dl dd').each(function() {
  48. $td = $('<td></td>');
  49. $td.html($(this).html());
  50. $tr.append($td);
  51. });
  52. $tbody.append($tr);
  53. });
  54. $table.append($tbody);
  55. $(this).replaceWith($table);
  56. //$(this).hide();
  57. });
  58. }
  59. }, false);