Paypal packing slip link
By nancy
—
Last update Sep 23, 2007
—
Installed
71 times.
// Paypal packing slip link
// Sept 22, 2007
// Copyright (c) 2007, Nancy Walsh
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script. To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Paypal packing slip link", and click Uninstall.
//
// On the accounts page, any items in the table that have 'Print shipping label'
// button will now also have a 'Packing slip' link to take you directly
// to the packing slip for that order.
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Paypal packing slip link
// @namespace http://www.knitfoundry.com
// @description Add a print invoice link to main paypal page
// @include https://www.paypal.com/us/cgi-bin/webscr?cmd=_account
// @include https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-done*
// ==/UserScript==
function xpath(query) {
return document.evaluate(query, document, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}
var allLinks, thisLink;
var INFO_STRING = 'info=';
var PACKSLIP_URL = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_shipping-receipt&'
allLinks = xpath('//a[@href]');
// Loop through all the links on the page to find the one we want
for (var i = 0; i < allLinks.snapshotLength; i++) {
thisLink = allLinks.snapshotItem(i);
// _ship-now is in the link we are looking for
if (thisLink.href.indexOf('_ship-now') > 0) {
var transId, linktext, infoindex;
// Determine the magic number to get to the right transaction
linktext = thisLink.href.toLowerCase();
infoindex = linktext.lastIndexOf(INFO_STRING);
if (infoindex != -1) {
// Build new link
transId = thisLink.href.substring(infoindex);
// Remove all additional parameters to the _ship-now link. we don't need 'em.
if (transId.indexOf('&') != -1) {
transId = transId.substring(0, transId.indexOf('&'));
}
// Create our new link element
var newLink = document.createElement('a');
newLink.href = PACKSLIP_URL + transId;
newLink.innerHTML="Packing Slip";
// INSERT THE LINK before print shipping label button
thisLink.parentNode.insertBefore(newLink, thisLink);
// Separate the new link from the rest of the stuff
var otherText = document.createElement('p');
thisLink.parentNode.insertBefore(otherText, thisLink);
}
}
}