Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// ==UserScript==
// @name Amazon Returns Label reformat
// @namespace h
// @version 1.2
// @description adds some line breaks so that a UPS or FedEx half-sheet adhesive label can be used
// @author JR Hehnly ( @stormchasing)
// @license GPL version 3 or any later version;
// @match*
// ==/UserScript==
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <>.
// History
// 05/2017 v1.1 JR Hehnly ( @stormchasing)
// Updated to add additional line breaks to properly format label page
// 12/2018 v1.2 JR Hehnly ( @stormchasing)
// Upadted retrun label triggering URL, label image class name and number of line breaks needed
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = [];
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
return (arrReturnElements);
function runMe() {
var brDiv = document.createElement('div');
brDiv.innerHTML = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>";
var imageNode = getElementsByClassName(document, 'img', 'return-label-image cut-line-sign')[0];
imageNode.parentNode.insertBefore(brDiv, imageNode);
setTimeout(runMe, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment