Phabricator - Mark as read without confirmation needed

Make "Marking all notifications as read" a one-click operation instead of a two-clicks operation (with the nagging modal)

  1. // ==UserScript==
  2. // @name Phabricator - Mark as read without confirmation needed
  3. // @namespace http://tampermonkey.net/
  4. // @description Make "Marking all notifications as read" a one-click operation instead of a two-clicks operation (with the nagging modal)
  5. // @version 0.1
  6. // @author Damien <damien@dam.io>
  7. // @include https://phabricator.*.*/*
  8. // @grant MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var template = '' +
  15. '<form method="POST" class="" data-sigil="jx-dialog" style="display: inline;">' +
  16. '<input type="hidden" name="__csrf__" value="B@f4f3n7j716a1a0c4e2494b01">' +
  17. '<input type="hidden" name="__form__" value="1">' +
  18. '<input type="hidden" name="__dialog__" value="1">' +
  19. '<input type="hidden" name="chronoKey" value="99999999999999999999999999" data-sigil="aphront-dialog-application-input">' +
  20. '<button name="__submit__" type="submit" data-sigil="__default__" data-meta="5_0" style="margin-top: 10px;background: inherit;border: none;">' +
  21. 'Mark All Read' +
  22. '</button>' +
  23. '</form>';
  24.  
  25. // add menu button
  26. var menu = document.querySelector('.phabricator-main-menu.phabricator-main-menu-background');
  27. var notifIcon = document.querySelector('.phabricator-main-menu-alerts');
  28. var markRead = document.createElement('span');
  29. markRead.innerHTML = template;
  30.  
  31. // add csrf token
  32. var token = document.querySelector('form[action="/search/"]').querySelector('input[name="__csrf__"]').value;
  33. markRead.querySelector('input[name="__csrf__"]').value = token;
  34. menu.appendChild(markRead, notifIcon);
  35. })();