Last active
June 19, 2017 12:07
-
-
Save tonymarklove/15dfc33ce22543afb69fd96024d2b9c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Zoho Estimate Plugin | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Add button for converting Zoho estimates to purchase and sales orders. | |
| // @author You | |
| // @include https://books.zoho.eu/app | |
| // @grant GM_log | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function createLinkElement(text, href) { | |
| var a = document.createElement('a'); | |
| var linkText = document.createTextNode(text); | |
| a.appendChild(linkText); | |
| a.href = href; | |
| a.className = "btn btn-default"; | |
| a.target = "_blank"; | |
| return a; | |
| } | |
| function perform(waitTime) { | |
| waitTime = waitTime || 100; | |
| setTimeout(function() { | |
| var match = location.hash.match(/#\/quotes\/(\d+)\?/); | |
| if (!match) { | |
| return; | |
| } | |
| var estimateId = match[1]; | |
| var replacedElement = document.querySelector(".content-column .btn-toolbar > button"); | |
| if (!replacedElement) { | |
| perform(waitTime * 2); | |
| return; | |
| } | |
| var linkHref = "https://portal.steelscout.com/zoho?enquiryId=" + estimateId; | |
| var newLinkElement = createLinkElement("Convert to Purchase Orders", linkHref); | |
| replacedElement.parentNode.replaceChild(newLinkElement, replacedElement); | |
| }, waitTime); | |
| } | |
| window.addEventListener("popstate", perform); | |
| perform(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment