Thinking Large

By ZingoTech Labs Last update Jul 5, 2007 — Installed 686 times. Daily Installs: 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 0, 2, 0, 0
//
// Thinking Large
// Make Playboy's CyberClub galleries skip the medium-sized photos and 
// link directly to the large-sized versions.
//
// Version 04 (5 July 2007)
// ZingoTech Labs
//
// Notes:
//
// * Set LRG_CENTERFOLD to true if you want to link directly to the 
//   large-sized centerfolds.  This is off by default due to the file size
//   of these pictures.
//
// Changelog:
//
// 01:  - Initial release.
//
// 02:  - Simplified code.
//      - Used @exclude rather than code to prevent modifying *-lrg.html 
//        and */centerfold.html files.
//      - Fixed bug where centerfold-med.html links were being converted
//        to centerfold-lrg.html rather than centerfold.html.
//      - Added option to not directly link to the large centerfold files.
//
// 03:  - Changed logic to only parse anchors when linking to a *-med.html 
//        location.
//
// 04:  - Using XPath for element traversal.
//
// ==UserScript==
// @name            Thinking Large
// @namespace       tag:zingospace-001
// @description     Make Playboy's CyberClub galleries skip the medium-sized photos and link directly to the large-sized versions.  Read source for additional notes.
// @include         http://cyber.playboy.com/*
// @exclude         http://cyber.playboy.com/*-lrg.html
// @exclude         http://cyber.playboy.com/*/centerfold.html
// ==/UserScript==
//

(function()
{

    var LRG_CENTERFOLD = false;

    // first find all anchors pointing to images, but exclude centerfolds
    // (handled on next loop, if specified with boolean above)
    anchors = document.evaluate(
        "//a[contains(@href, '-med.html') and not(contains(@href, 'centerfold-med.html'))]",
        document,
        null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
        null);

    length = anchors.snapshotLength;
    for(ctr = 0; ctr < length; ctr++)
    {
        anchor = anchors.snapshotItem(ctr);
        anchor.href = anchor.href.replace(/-med.html/, "-lrg.html");
    }

    if(LRG_CENTERFOLD)
    {
        // find all anchors pointing to centerfold ... the issue here is that
        // (a) large centerfolds can be rather large, and some users might want
        // to preview medium-sized before going on, and (b) the above replace logic does not apply,
        // as centerfold-med.html -> centerfold.html (no -lrg).
        anchors = document.evaluate(
            "//a[contains(@href, 'centerfold-med.html')]",
            document,
            null,
            XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
            null);

        length = anchors.snapshotLength;
        for(ctr = 0; ctr < length; ctr++)
        {
            anchor = anchors.snapshotItem(ctr);
            anchor.href = anchor.href.replace(/centerfold-med.html/, "centerfold.html");
        }
    }

})();