Last active
December 22, 2018 16:51
-
-
Save stormchasing/e5be3b735c24d1e1bd7a40b139aa9551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Amazon Returns Label reformat | |
// @namespace hhttp://www.okstorms.com/ | |
// @version 1.2 | |
// @description adds some line breaks so that a UPS or FedEx half-sheet adhesive label can be used | |
// @author JR Hehnly (http://www.okstorms.com @stormchasing) | |
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html | |
// @match https://www.amazon.com/spr/returns/label/* | |
// ==/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 | |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
// 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 <http://www.gnu.org/licenses/>. | |
// | |
// History | |
// | |
// 05/2017 v1.1 JR Hehnly (http://www.okstorms.com @stormchasing) | |
// Updated to add additional line breaks to properly format label page | |
// 12/2018 v1.2 JR Hehnly (http://www.okstorms.com @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]; | |
if(oRegExp.test(oElement.className)){ | |
arrReturnElements.push(oElement); | |
} | |
} | |
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