// ==UserScript==
// @name Newegg Camel Graph
// @version 1.0.0
// @description Add Camelegg graph + link to Newegg product pages.
// @namespace null
// @include http://www.newegg.*/*
// @include http://*.camelegg.com/*
// @include http://camelegg.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// @downloadURL https://update.greasyfork.icu/scripts/5197/Newegg%20Camel%20Graph.user.js
// @updateURL https://update.greasyfork.icu/scripts/5197/Newegg%20Camel%20Graph.meta.js
// ==/UserScript==
var width = 300;
var height = 250;
var chart = "newegg";
var arr = document.domain.split(".");
var country = arr[arr.length - 1];
if (country=="com") {country = "us";}
var url = window.location.href;
var pattern = "http://www.newegg.com/Product/Product.aspx([?])Item=([A-Z0-9]{0,25}).*";
var exp = new RegExp(pattern, "gi");
var asin = url.replace(exp,"$2");
var element = $(':input[id="hiddenItemNumber"]');
var asin2 = $.trim(element.attr("value"));
if (asin.length < asin2.length) {asin=asin2;}
var link2 = "";
var camelurl = 'http://' + country + '.camelegg.com/product/' + asin;
GM_xmlhttpRequest({
method: 'GET',
url: camelurl,
onload: function(response) {
var parser = new DOMParser ();
var responseDoc = parser.parseFromString (response.responseText, "text/html");
if (!responseDoc.getElementById('chart_option_details').disabled) {
$("#BrandLiveChat").append("