CubecraftHideLockedThreads

Adds an option to hide locked threads on the cubecraft forums.

当前为 2016-08-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CubecraftHideLockedThreads
  3. // @namespace de.rasmusantons
  4. // @description Adds an option to hide locked threads on the cubecraft forums.
  5. // @include https://www.cubecraft.net/forums/*/*
  6. // @version 2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. function updateThreadList(hideLocked) {
  11. var lockedThreads = $('.discussionListItem.locked');
  12. lockedThreads.each(function(i, e) {
  13. var thread = $(e);
  14. thread.css('display', hideLocked ? 'none' : '');
  15. });
  16. cnt.text(hideLocked ? '(' + lockedThreads.length + ' locked threads hidden)' : '');
  17. }
  18.  
  19. function onCbChange() {
  20. localStorage.setItem('hideLocked', this.checked);
  21. updateThreadList(this.checked);
  22. }
  23.  
  24. var cb = $('<input type="checkbox" />');
  25. var cnt = $('<span></span>');
  26. cnt.css('margin-left', '5px');
  27. cb.get(0).checked = (localStorage.getItem('hideLocked') == "true");
  28. updateThreadList(cb.get(0).checked);
  29. cb.change(onCbChange);
  30. $($('.secondaryContent > .col2')[0]).append($('<li></li>').append($('<a></a>').append($('<label>hide locked threads</label>').prepend(cb))));
  31. $($('.sectionFooter.SelectionCountContainer')[0]).append(cnt);