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)

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Phabricator - Mark as read without confirmation needed
// @namespace    http://tampermonkey.net/
// @description  Make "Marking all notifications as read" a one-click operation instead of a two-clicks operation (with the nagging modal)
// @version      0.1
// @author       Damien <[email protected]>
// @include      https://phabricator.*.*/*
// @grant        MIT
// ==/UserScript==

(function() {
    'use strict';

    var template = '' +
        '<form method="POST" class="" data-sigil="jx-dialog" style="display: inline;">' +
        '<input type="hidden" name="__csrf__" value="B@f4f3n7j716a1a0c4e2494b01">' +
        '<input type="hidden" name="__form__" value="1">' +
        '<input type="hidden" name="__dialog__" value="1">' +
        '<input type="hidden" name="chronoKey" value="99999999999999999999999999" data-sigil="aphront-dialog-application-input">' +
        '<button name="__submit__" type="submit" data-sigil="__default__" data-meta="5_0" style="margin-top: 10px;background: inherit;border: none;">' +
        'Mark All Read' +
        '</button>' +
        '</form>';

    // add menu button
    var menu = document.querySelector('.phabricator-main-menu.phabricator-main-menu-background');
    var notifIcon = document.querySelector('.phabricator-main-menu-alerts');
    var markRead = document.createElement('span');
    markRead.innerHTML = template;

    // add csrf token
    var token = document.querySelector('form[action="/search/"]').querySelector('input[name="__csrf__"]').value;
    markRead.querySelector('input[name="__csrf__"]').value = token;
    
    menu.appendChild(markRead, notifIcon);
})();