Greasy Fork 还支持 简体中文。

Slack Web Helper

Enhances Slack web app.

  1. // ==UserScript==
  2. // @name Slack Web Helper
  3. // @description Enhances Slack web app.
  4. // @author dearrrfish (http://github.com/dearrrfish)
  5. // @version 1.0.1
  6. // @namespace http://github.com/dearrrfish
  7. // @include https://app.slack.com/client/*
  8. // @grant GM_addStyle
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. const onLoad = callback => {
  15. const loadedStates = ['loaded', 'interactive', 'complete'];
  16. if (loadedStates.includes(document.readyState)) {
  17. callback();
  18. }
  19. else {
  20. window.addEventListener('load', () => {
  21. callback();
  22. });
  23. }
  24. };
  25.  
  26. // GM_addStyle(`
  27.  
  28. // @media screen and (max-width: 700px) {
  29.  
  30. // .c-search_modal > .popover {
  31. // min-width: unset !important;
  32. // }
  33.  
  34. // .p-workspace-layout {
  35. // grid-template-areas:
  36. // "p-workspace__sidebar p-workspace__primary_view"
  37. // "p-workspace__sidebar p-workspace__secondary_view" !important;
  38. // grid-template-columns: 0 auto !important;
  39. // grid-template-rows: auto min !important;
  40. // }
  41.  
  42. // .p-workspace__secondary_view {
  43.  
  44. // }
  45. // }
  46. // `)
  47.  
  48. onLoad(() => {
  49.  
  50. // Click new unread message button automatically
  51. setInterval(() => {
  52. const newMessageButton = document.querySelector('.p-workspace-layout .p-unreads_view__empty--show_new > button');
  53. const newMessageSyncButton = document.querySelector('.p-workspace-layout > div[aria-label="All unreads"] .p-ia__view_header > button:not(.p-ia__view_header__sidebar_toggle_button');
  54. if (newMessageButton) {
  55. newMessageButton.click();
  56. }
  57. if (newMessageSyncButton) {
  58. newMessageSyncButton.click();
  59. }
  60. }, 5000)
  61.  
  62. });
  63. })();