Last active
May 26, 2021 07:23
-
-
Save skyghis/3ffdf6d93d83d4616212ec7a6da8e690 to your computer and use it in GitHub Desktop.
Display camel graph inside amazon product pages
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 Amazon Camel Graph Revived/Fixed | |
// @version 1.3.0 | |
// @description Add CamelCamelCamel graph + link to Amazon product pages. | |
// @namespace https://gist.github.com/skyghis/3ffdf6d93d83d4616212ec7a6da8e690 | |
// @updateURL https://gist.github.com/skyghis/3ffdf6d93d83d4616212ec7a6da8e690/raw | |
// @include http*://www.amazon.*/* | |
// @icon https://camelcamelcamel.com/favicon.ico | |
// @author SkyghiS | |
// @homepageURL https://gist.github.com/skyghis/3ffdf6d93d83d4616212ec7a6da8e690 | |
// ==/UserScript== | |
var country = document.domain.split('.').slice(-1)[0]; | |
country = country == 'com' ? 'us' : country; | |
var asin = document.getElementById('ASIN').value; | |
var camelGraph = document.createElement('img'); | |
camelGraph.src = '//charts.camelcamelcamel.com/' + country + '/' + asin + '/amazon-new.png?legend=1&fo=1&w=700'; | |
var camelLink = document.createElement('a'); | |
camelLink.target = 'blank'; | |
camelLink.href = '//' + country + '.camelcamelcamel.com/product/' + asin; | |
camelLink.appendChild(camelGraph); | |
var camelDivGraph = document.createElement('div'); | |
camelDivGraph.style.marginLeft = '-10px' | |
camelDivGraph.appendChild(camelLink); | |
var camelToggle = document.createElement('i'); | |
camelToggle.classList.add('a-icon'); | |
camelToggle.classList.add('a-icon-section-collapse'); | |
camelToggle.style.cursor = 'zoom-out'; | |
camelToggle.onclick = function() { | |
camelToggle.classList.remove('a-icon-section-collapse', 'a-icon-section-expand'); | |
if (camelDivGraph.style.display === 'none') { | |
camelToggle.classList.add('a-icon-section-collapse'); | |
camelToggle.style.cursor = 'zoom-out'; | |
camelDivGraph.style.display = ''; | |
} else { | |
camelToggle.classList.add('a-icon-section-expand'); | |
camelToggle.style.cursor = 'zoom-in'; | |
camelDivGraph.style.display = 'none'; | |
} | |
}; | |
var camelDivInfos = document.createElement('div'); | |
camelDivInfos.style.marginLeft = '-10px' | |
camelDivInfos.appendChild(camelToggle); | |
var destination = document.getElementById('unifiedPrice_feature_div'); | |
destination.appendChild(camelDivInfos); | |
destination.appendChild(camelDivGraph); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly what I was looking for since the official Firefox Add-on doesn't work for my country. Thanks!