NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name GlassNetAutoVRM // @namespace http://gnnew.glass-net.co.uk/ // @version 0.2.2 // @description [OBSOLETE] Auto populates the Glass Net lookup form with the VRM and miles, and more... // @match http://example.com // @copyright 2015 - A subscriber who wanted more. // @require https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.js // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== $(document).ready(function() { /* var isMobile = false; var main = function() { var path = window.location.pathname.substr(1); var params = null; if (window.location.hash) { var hash = decodeURIComponent(window.location.hash.substr(1)); try { params = JSON.parse(hash); } catch (e) { console.log("Couldn't parse '" + hash + "': " + e); } } if (!params) { params = {}; // Parse the URI and extract all the QueryString name-value pairs querystring = window.location.search; querystring = querystring.substring(querystring.indexOf('?')+1).split('&'); var pair, d = decodeURIComponent; // march and parse for (var i = querystring.length - 1; i >= 0; i--) { pair = querystring[i].split('='); params[d(pair[0])] = d(pair[1]); } } isMobile = (path === "mobile-index"); if (path === "" || path === "index" || path === "Default.aspx" || path === "mobile-index") { if (params.glassCode) { } else if (params.vrm || params.miles) { vrmLookup(params.vrm, params.miles); } } else if ((/^(mobile-vehicle\/vehicle-valuation|mobile-vrm-lookup)/).test(path)) { //addGlassCodeLink(); injectCopyValuation(); } }; var injectCopyValuation = function() { var button = $("<input>", { type: "button", value: "Copy Valuation Values", "class": "mainBT w0BT", }); button.on("click", function(e) {return false;}); $("input[name='mileage_submit']").after(button); ZeroClipboard.config( { swfPath: "//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.swf" } ); var client = new ZeroClipboard(button); client.on("ready", function(e) { client.on("copy", ZeroClipboard_copy); }); }; var vrmLookup = function(vrm, miles) { // Round miles up to the next 1000 if (miles) miles = 1000 * Math.ceil(miles / 1000, 0); if (vrm) { if (isMobile) { $("#registration_number").val(vrm.toUpperCase()); } else { $("#vrms_reg_no").val(vrm.toUpperCase()); } } if (miles) { if (isMobile) { $("#mileage").val(miles); } else { $("#vrms_mileage").val(miles); } } // Only execute the search if we have both the VRM and the Mileage if (vrm && miles) { if (isMobile) { $("#login_submit").trigger("click"); } else { $("#find_value_vrm").trigger("click"); } } }; var ZeroClipboard_copy = function(e) { var data = {}; var container = $(".valuation_result"); data.GlassValue = parseInt(container.find("span:contains('Basic value')").first().next().text().replace(/[^0-9.]/g, "")); data.GlassTotal = parseInt(container.find("span:contains('Adjusted value total')").first().next().text().replace(/[^0-9.]/g, "")); data.GlassAdjustmentMiles = parseInt($("#mileage").val()) / 1000; data.GlassDate = $(".val_from").text().replace(/Valuation for /, ""); // Vehicle description data.GlassNotes = $("div.fl.head_techinfo").text(); var text = ""; for (var key in data) { text += key + ":" + data[key] + "\n"; } e.clipboardData.setData("text/plain", text); }; main(); */ });