De-embed AusPost PDFs

The Australia Post eParcel site wraps label PDF downloads in an <object> tag that interferes with browsers' normal PDF display and printing. This script "unwraps" those PDF links.

// ==UserScript==
// @name         De-embed AusPost PDFs
// @namespace    mailto:[email protected]
// @esversion    6
// @version      1.0
// @description  The Australia Post eParcel site wraps label PDF downloads in an <object> tag that interferes with browsers' normal PDF display and printing. This script "unwraps" those PDF links.
// @author       Roy-Orbison
// @include      https://eparcel.auspost.com.au/eParcel/merchant/auth/viewLabelsDownload.do
// @include      https://online.auspost.com.au/eParcel/merchant/auth/viewLabelsDownload.do
// @run-at       document-end
// ==/UserScript==

(function(pdfPath, loc) {
    pdfPath = loc.protocol + '//' + loc.host + pdfPath;
    unsafeWindow.openPDFWindow = function(indirectReference) {
        unsafeWindow.open(pdfPath + indirectReference);
    };
    unsafeWindow.replaceWindowWithPDF = function(indirectReference) {
        unsafeWindow.location = pdfPath + indirectReference;
    };
})('/eParcel/merchant/auth/submitLabelsDownload.do?autoPrint=true&temporaryPdfSysId=', unsafeWindow.location);