Skip to content

Instantly share code, notes, and snippets.

@miguel-perez
Created May 11, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguel-perez/cc47311c84cfc1c16dde8c358271cac2 to your computer and use it in GitHub Desktop.
Save miguel-perez/cc47311c84cfc1c16dde8c358271cac2 to your computer and use it in GitHub Desktop.
Inject desired changes to a site using javascript
// IIFE for protection
;(function(win, doc, $){
var
newStyles = [
'<style>',
'.home .navbar-inverse .navbar-nav > li a:hover {',
'background-color: #f56226;',
'transition: background-color ease-in-out 0.5s;',
'}',
'.home .jumbotron {',
'background-image: url("https://trello-attachments.s3.amazonaws.com/54fdbbb6dfe596eb550fca5b/1000x750/95aa8c654a2da7b1dfe8bba989b58677/upload_10_19_2015_at_2_53_50_PM.png"),',
'background-size: contain,',
'background-repeat: no-repeat,',
'background-color: #fff,',
'background-position: center center',
'}',
'</style>'
].join(''),
$body = $(document.body),
$title = $('.home .container h1'),
$ourServices = $('#menu-item-136'),
$jumbotron = $('.home .jumbotron'),
$mainCTA = $('.home .jumbotron [data-target="#contact-modal"]');
// Inject new styles
$body.prepend(newStyles);
// Update title
$title.html('We help our clients grow through data-driven experimentation.');
// Remove our services link
$ourServices.remove();
// Update CTA
$mainCTA
.html('Our Services')
.on('click', function(e){
e.stopPropagation();
window.location = 'http://crometrics.com/our-services/';
})
})(window, document, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment