User:Learn more/Tampermonkey

From ReactOS Wiki
Jump to: navigation, search

Tampermonkey scripts

Expand mailing list threaded view inline

// ==UserScript==
// @name         ros-dev Expand threaded view inline
// @namespace    https://www.reactos.org/pipermail/ros-dev/
// @version      0.3
// @description  try to take over the world!
// @author       Mark Jansen
// @match        https://www.reactos.org/pipermail/ros-dev/*/thread.html
// @match        https://www.reactos.org/mailman/private/ros-priv/*/thread.html
// @match        https://www.winehq.org/pipermail/wine-devel/*/thread.html
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';
$('li a').each(function() {
    var href2 = $(this).attr('href');
    var ohref = this.href;
    if (typeof href2 !== typeof undefined && ohref != href2 && ohref.indexOf('#') < 0) {
        var span = $('<span>[+] </span>').insertBefore($(this));
        
        var href = this.href; // Full href (for loading)
        var id = $(this).attr('href').replace(/\.[^/.]+$/, "");  // partial href (to use as id)

        var parent = $(this).parent();
        var oth = parent.children('ul');
        var loading = $('<div class="' + id + '" style="display: none;">Loading...</div>');
        if (oth.length > 0) {
            loading.insertBefore(oth.first());
        } else {
            loading.appendTo(parent);
        }
        span.addClass(id).css('font-family', 'Courier, monospace').css('cursor', 'pointer');
        
        span.on('click', {id:id, href:href}, function(e){
            var id = e.data.id;
            var href = e.data.href;
            $('div.' + id).toggle().load(href + ' pre');
            $('span.' + e.data.id).text('[-] ');
            
            $(this).off('click').on('click', {id:id}, function(e){
                var elem = $('div.' + e.data.id);
                $('span.' + e.data.id).text(elem.is(":visible") ? '[+] ' : '[-] ');
                elem.toggle();
            });
        });
    }
});
})();


Add links to the Jira dasboard 'Quick links' item

// ==UserScript==
// @name         AddLinks
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Add new links to the quick links box
// @author       Mark Jansen
// @match        https://jira.reactos.org/secure/Dashboard.jspa
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var links = [
        '<a href="//reactos.org/testman/" target="_blank">Testman</a>',
        '<a href="//build.reactos.org/builders" target="_blank">Buildbot</a>',
        ];
    
    $('#gadget-12400-chrome > .dashboard-item-content').append('<div><center>' + links.join(' | ') + '</center></div>');

})();


Highlight some tests in testman

// ==UserScript==
// @name         Highlight some testman tests
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Mark Jansen
// @match        https://reactos.org/testman/*
// @match        https://www.reactos.org/testman/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';
    var tests = [
            'atl:CComBSTR',
            'atl:CComHeapPtr',
            'ntdll:NtMapViewOfSection',
            'ntdll:NtApphelpCacheControl',
            'ole32:initializespy',
            'pefile:ntoskrnl_SectionFlags',
            'sdk:delayimp',
            'shell32:assoc',
            'shell32:CShellDesktop',
            'shell32:shelldispatch',
            'wintrust:softpub',
            'msgina:ShellDimScreen',
            'atl:atltypes',
            'atl:CRegKey',
            'atl:CString',
            'msvcrt_crt:__getmainargs'
            'gdi32_apitest:AddFontMemResourceEx'
            ];
    var result = 'tr[title="' + tests.join('"],tr[title="') + '"],tr[title^="apphelp:"],tr[title^="appshim:"]';

    $('iframe').load( function() {
        $('iframe').contents().find("head")
            .append($('<style type="text/css">' + result + '{ font-weight: bold; color: red; }' + '</style>'));
    });
    $("head").append($('<style type="text/css">' + result + '{ font-weight: bold; color: red; }' + '</style>'));

})();

Easy patch submit to buildbot

2 scripts!

// ==UserScript==
// @name         Patchbot links
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Mark Jansen
// @match        https://jira.reactos.org/browse/CORE-*
// @match        https://jira.reactos.org/browse/ROSTESTS-*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $('ol.item-attachments li dl dt a').each(function()
                                  {
        var issue = window.location.pathname;
        var x2 = issue.match(/\/browse\/([A-Z]+)-(\d*)/);
        var issuetype = x2[1];
        var issueid = x2[2];
        var patch = $(this).attr('href');
        var patchid = patch.match(/\/secure\/attachment\/(\d*)/)[1];
        //
        var full_url = 'https://build.reactos.org/builders/Build%20GCCLin_x86?force&issue=' + issuetype + '-' + issueid + '&patch=' + patchid;
        $(this).parent().parent().append('<dd><a href="' + full_url + '" target="_blank" style="margin-right:20px;">Testbot</a>&nbsp</dd>');
        full_url = 'https://build.reactos.org/builders/Test%20KVM%20AHK?force&issue=' + issuetype + '-' + issueid + '&patch=' + patchid;
        $(this).parent().parent().append('<dd><a href="' + full_url + '" target="_blank" style="margin-right:20px;">AHK</a>&nbsp</dd>');
        //alert('' + patchid + '|' + issueid);
    });

})();


// ==UserScript==
// @name         Patchbot fill in values
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Mark Jansen
// @match        https://build.reactos.org/builders/Build%20GCCLin_x86?force&issue=*
// @match        https://build.reactos.org/builders/Test%20KVM%20AHK?force&issue=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    var query_string = {};
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        query_string[pair[0]] = decodeURIComponent(pair[1]);
    }
    if (typeof query_string.issue !== "undefined" &&
       typeof query_string.patch !== "undefined")
    {
        var x = document.getElementsByName("reason");
        if (x.length > 0) { x[0].value = query_string.issue; }
        x = document.getElementsByName("property1_name");
        if (x.length > 0) { x[0].value = 'id'; }
        x = document.getElementsByName("property1_value");
        if (x.length > 0) { x[0].value = query_string.patch; }
    }

})();