GitHub: Issue sort:updated-desc Button

Add top level button to sort both issues/pull requests by the most recently updated.

اعتبارا من 15-06-2016. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name            GitHub: Issue sort:updated-desc Button
// @description     Add top level button to sort both issues/pull requests by the most recently updated.
// @author          Chris H (Zren / Shade)
// @icon            https://github.com/favicon.ico
// @namespace       http://xshade.ca
// @version         3
// @include         https://github.com*
// ==/UserScript==

(function(uw){
    
    var createElement = function(html) {
        var e = document.createElement('div');
        e.innerHTML = html;
        return e.firstChild;
    };

    var blameUrlPattern = /^https:\/\/github.com\/[^\/]+\/[^\/]+\/(issues|pulls)/;

    var main = function() {
        var m = blameUrlPattern.exec(document.location.href);
        if (!m)
            return;
        
        if (document.getElementById('sort-issues-recently-updated'))
            return;

        Array.prototype.forEach.call(document.querySelectorAll('.table-list-header-toggle.right'), function(e) { 
            var url = m[0] + '?q=sort%3Aupdated-desc';
            var html = '<div class="left"><a id="sort-issues-recently-updated" class="btn-link icon-only js-menu-target" role="button" aria-haspopup="true" style="padding-right: 15px; padding-left: 15px;" href="' + url + '">sort:recently-updated</a></div>';
            var a = createElement(html);
            e.insertBefore(a, e.firstChild);
        });
    };

    main();
    
    //var $ = uw.$;
    //$(document).on('pjax:end', main);
    setInterval(main, 1000);

})(typeof unsafeWindow === 'undefined' ? window : unsafeWindow);