BelarcHotfixSearch

By palisade Last update Sep 14, 2008 — Installed 40 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name           BelarcHotfixSearch
// @namespace      belarc
// @description    Searches Microsoft Download Center for relevant security hotfixes found using Belarc Advisor.
// @include        file:///C:/Program%20Files/Belarc/Advisor/System/tmp/(*).html
// ==/UserScript==

// ChangeLog
// 9/13/08: initial creation

var loc;
var msdownloads;
var links;
var td;

// post process the page after rendering
window.addEventListener(
    'load', 
    function() {
        // set up globals
        loc = decodeURI(window.location);

        msdownloads = "http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=%s&DisplayLang=en";
        links = document.getElementsByTagName('a');
        td = document.getElementsByTagName('td');

        // perform the main processing
        Main();
    },
    true);

function Main() {
 var linkCount = 0;

 for (var i = 0; i < links.length; i++) {
    var href = links[i].href;

    if (href.indexOf("qferefer?") > 0) {

        // finds the name of the hotfix
        var hotfix = href.substr(href.indexOf("?Q")+2);

        var link = document.createElement('a');
        link.href=    (msdownloads.replace(/%s/, hotfix));
        link.title=   "Download";
        link.target=  "_blank"; // launches in a new tab

        link.appendChild( document.createTextNode(' Find') );

        var parent = links[i].parentNode;
        if (parent) {
            parent.insertBefore(link, parent.nextSibling);
        }
    }
 }
}