Last active
October 13, 2020 18:37
-
-
Save happiness801/976f92e0491f9b16ccd835ebb7ff5fb0 to your computer and use it in GitHub Desktop.
Amazon: Inject CamelCamelCamel Link
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 Inject CamelCamelCamel Link | |
// @namespace http://onai.net/ | |
// @version 0.4 | |
// @description Makes product title a link to CamelCamelCamel | |
// @author Kevin Gwynn | |
// @match https://*.amazon.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let injectCccLink = function() { | |
console.log('KAG: attempt to inject CCC link...'); | |
// Inject jQuery | |
var gen = 0;var act=function(){gen=1;var script=document.createElement('script');script.src='//code.jquery.com/jquery-1.11.0.min.js';script.type='text/javascript';document.getElementsByTagName('head')[0].appendChild(script);};(!window.jQuery)?act():1;setTimeout(function(){console.log('jQuery '+(gen?'loaded: ':'existing: ')+(window.jQuery?jQuery().jquery:'no jQuery/load failed'));}, 500); | |
var $ = jQuery; | |
// started this, but couldn't reproduce the modal to test :-P | |
let amazonUrl = document.location.href; | |
let amazonProductId = amazonUrl.replace(/.*\/(?:dp|product)\/([^?\/]+).*/, '$1'); | |
let titleHtml = jQuery('#productTitle').html(); | |
titleHtml = '<a href="https://camelcamelcamel.com/product/' + amazonProductId + '">' + titleHtml + '</a>'; | |
jQuery('#productTitle').html(titleHtml); | |
}; | |
setTimeout(injectCccLink, 1500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment