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)

Από την 29/06/2016. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);
})();