Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Online .NET Class Library Reference

Name: Anonymous 2007-08-04 14:28 ID:fpfgV+up

Is there one excluding that one at microsoft.com? That site is just terrible, I can't use it.

Name: Anonymous 2007-08-05 11:45 ID:3qXM02MS

Anyway, here's the solution:


// ==UserScript==
// @name          .NET CLR defailer
// @description   Makes Microsofts on-line .NET Framework Class Library Reference at http://msdn2.microsoft.com/en-us/library/ms229335.aspx fail less. Basically removes noise.
// @namespace     tag:LolipopLaboratoriesIncorporated,2007-08-04:.NET_CLR_defailer
// @include       http://msdn2.microsoft.com/en-us/library/*;
// ==/UserScript==

// uncomment and drop the fallowing thr33 lines in your prefs.js, otherwise you'll get hit by print dialog on every page. sorry, monkey can't work this
// user_pref("capability.policy.policynames", "noprint");
// user_pref("capability.policy.noprint.sites", "http://msdn2.microsoft.com";);
// user_pref("capability.policy.noprint.Window.print", "noAccess");

// code examples in these languages will be removed
var languagesToRemove = ['VisualBasic', 'CPlusPlus', 'JSharp', 'JScript', 'other'];

// redirect to print friendly page, if not there
if (!window.location.href.match(/d=print/))
{
    window.location.href = urlToPrinter(window.location.href);
}

// rewrites url to print friendly page
function urlToPrinter(url)
{
    var url = unescape(url);
    if (/\)\.aspx$/.test(url))
        return url.replace(/\)\.aspx$/, ',d=printer).aspx');
    else
        return url.replace(/\.aspx$/, '(d=printer).aspx');
}

// lol, xpath. is it turing complete yet?
function xpath(query)
{
    return document.evaluate(query, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}

// remove, rewrite, rewire, make it usable
function onDocumentLoad()
{
    // removing print friendly anchor explanations
    document.body.innerHTML = document.body.innerHTML.replace(/(\<\/a\>)\s*\[\s*http.*?\]/g, '$1'); // where TF is my (?<=)?
    // removing logo and copyrites
    var noise = xpath("//td[@class='PFB_Left' or @class='PFB_Right']/parent::tr");
    if (noise.snapshotLength > 0)
        noise.snapshotItem(0).parentNode.removeChild(noise.snapshotItem(0));
    // removing unwanted code examples
    while (languagesToRemove.length > 0)
    {
        var moreNoise = xpath("//div[contains(@id, '"+ languagesToRemove.shift() +"')]"); // and why can't we have ends-with?
        for (i = 0; i < moreNoise.snapshotLength; i++)
            moreNoise.snapshotItem(i).parentNode.removeChild(moreNoise.snapshotItem(i));
    }
    // rewiring anchors to print friendly pages
    var anchors = xpath('//a[@href]');
    for (i = 0; i < anchors.snapshotLength; i++)
        anchors.snapshotItem(i).href = urlToPrinter(anchors.snapshotItem(i).href);
}

// yes, plz
window.addEventListener("load", onDocumentLoad, false);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List