Skip to content

Instantly share code, notes, and snippets.

@scirelli
Created December 3, 2016 05:35
Show Gist options
  • Save scirelli/fab5fdabbd2d614fef43206b4e01d366 to your computer and use it in GitHub Desktop.
Save scirelli/fab5fdabbd2d614fef43206b4e01d366 to your computer and use it in GitHub Desktop.
Comcast Injecting Scripts
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<title>Day 1 - Advent of Code 2016</title>
<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/static/style.css?7"/>
<link rel="shortcut icon" href="/favicon.ico?2"/>
</head><!--
Oh, hello! Funny seeing you here.
I appreciate your enthusiasm, but you aren't going to find much down here.
There certainly aren't clues to any of the puzzles. The best surprises don't
even appear in the source until you unlock them for real.
Please be careful with automated requests; I'm not Google, and I can only take
so much traffic. Please be considerate so that everyone gets to play.
If you're curious about how Advent of Code works, it's running on some custom
Perl code. Other than a few integrations (auth, analytics, ads, social media),
I built the whole thing myself, including the design, animations, prose, and
all of the puzzles.
The puzzles probably took the longest; the easiest ones were around 45 minutes
each, but the harder ones took 2-3 hours, and a few even longer than that. A
lot of effort went into building this thing - I hope you're enjoying playing it
as much as I enjoyed making it for you!
If you'd like to hang out, I'm @ericwastl on Twitter.
- Eric Wastl
-->
<body>
<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2016/about">[About]</a></li><li><a href="/2016/support">[AoC++]</a></li><li><a href="/2016/events">[Events]</a></li><li><a href="/2016/settings">[Settings]</a></li><li><a href="/2016/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Steve Cirelli <span class="star-count">3*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">y(</span><a href="/2016">2016</a><span class="title-event-wrap">)</span></h1><nav><ul><li><a href="/2016">[Calendar]</a></li><li><a href="/2016/leaderboard">[Leaderboard]</a></li><li><a href="/2016/stats">[Stats]</a></li><li><a href="/2016/sponsors">[Sponsors]</a></li></ul></nav></div></header>
<div id="sidebar">
<div id="sponsor"><div class="quiet">Our <a href="/2016/sponsors">sponsors</a> help make AoC possible:</div><p><a href="http://www.novetta.com/careers/#opportunities" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);">Novetta</a> - Unleash your imagination. Innovate at Novetta.</p></div>
<div id="ad">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Advent of Code Wide Skyscraper -->
<ins class="adsbygoogle"
style="display:inline-block;width:160px;height:600px"
data-ad-client="ca-pub-9420604735624631"
data-ad-slot="8014013294"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div><!--/ad-->
</div><!--/sidebar-->
<main>
<article class="day-desc"><h2>--- Day 1: No Time for a Taxicab ---</h2><p>Santa's sleigh uses a <span title="An atomic clock is too inaccurate; he might end up in a wall!">very high-precision clock</span> to guide its movements, and the clock's oscillator is regulated by stars. Unfortunately, the stars have been stolen... by the Easter Bunny. To save Christmas, Santa needs you to retrieve all <em class="star">fifty stars</em> by December 25th.</p>
<p>Collect stars by solving puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants <em class="star">one star</em>. Good luck!</p>
<p>You're airdropped near <em>Easter Bunny Headquarters</em> in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start here, and nobody had time to work them out further.</p>
<p>The Document indicates that you should start at the given coordinates (where you just landed) and face North. Then, follow the provided sequence: either turn left (<code>L</code>) or right (<code>R</code>) 90 degrees, then walk forward the given number of blocks, ending at a new intersection.</p>
<p>There's no time to follow such ridiculous instructions on foot, though, so you take a moment and work out the destination. Given that you can only walk on the <a href="https://en.wikipedia.org/wiki/Taxicab_geometry">street grid of the city</a>, how far is the shortest path to the destination?</p>
<p>For example:</p>
<ul>
<li>Following <code>R2, L3</code> leaves you <code>2</code> blocks East and <code>3</code> blocks North, or <code>5</code> blocks away.</li>
<li><code>R2, R2, R2</code> leaves you <code>2</code> blocks due South of your starting position, which is <code>2</code> blocks away.</li>
<li><code>R5, L5, R5, R3</code> leaves you <code>12</code> blocks away.</li>
</ul>
<p><em>How many blocks away</em> is Easter Bunny HQ?</p>
</article>
<p>Your puzzle answer was <code>181</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Then, you notice the instructions continue on the back of the Recruiting Document. Easter Bunny HQ is actually at the first location you visit twice.</p>
<p>For example, if your instructions are <code>R8, R4, R4, R8</code>, the first location you visit twice is <code>4</code> blocks away, due East.</p>
<p>How many blocks away is the <em>first location you visit twice</em>?</p>
</article>
<p>Your puzzle answer was <code>140</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, you should <a href="/2016">return to your advent calendar</a> and try another puzzle.</p>
<p>If you still want to see it, you can <a href="1/input" target="_blank">get your puzzle input</a>.</p>
<p>You can also <span class="share">[Share<span class="share-content">on
<a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22No+Time+for+a+Taxicab%22+%2D+Day+1+%2D+Advent+of+Code+2016&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F1&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
<a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F1" target="_blank">Google+</a>
<a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F1&amp;title=I%27ve+completed+%22No+Time+for+a+Taxicab%22+%2D+Day+1+%2D+Advent+of+Code+2016" target="_blank">Reddit</a
></span>]</span> this puzzle.</p>
</main>
<!-- ga -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69522494-1', 'auto');
ga('send', 'pageview');
</script>
<!-- /ga -->
<script language="JavaScript" type="text/javascript">
// Copyright (C) 2015 Comcast Cable Communications, LLC
// Contact Us: http://customer.xfinity.com/contact-us/
// Intended use of this message is to display critical and time sensitive notifications to customers.
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
http://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html
*/
var _ComcastAlert = (function(){
return {
SYS_URL: '/e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do'
, dragObj: {zIndex: 999999}
, browser: null
, comcastCheck: 1
, comcastTimer: null
, xmlhttp: null
, go: function(){
if(self.location !== top.location) return;
if(document.body){
_ComcastAlert.ComcastBrowserNotice();
_ComcastAlert.browser = _ComcastAlert.checkBrowser();
_ComcastAlert.getXmlhttp();
_ComcastAlert.checkBulletin();
return _ComcastAlert;
}else{
setTimeout(_ComcastAlert.go, 200);
}
}
, ComcastBrowserNotice: function(){
var image_url = 'http://bnpsa.g.comcast.net:80/images/mydevicealert/browser/';
var comcastAlertAnalytics = 'DPE_Group-19_160076-D3_EOL_Speed_Own-50316_v1.png';
var notice_width = '600px';
var notice_height = '550px';
var winObj = {
image_url: image_url
, comcastAlertAnalytics: comcastAlertAnalytics
, notice_width: notice_width
, notice_height: notice_height
, comcastlogo_url: '<img src="' + image_url + 'comcast-logo-115x50.png" height="50" width="115"/>'
, xfinitylogo_url: '<img src="' + image_url + 'Xfinity-Logo-White-221x124.png" height="55" width="99"/>'
, headertext1: '<b>We&#39;ve increased Internet speeds in your area.</b>'
, headertext2: '<b>Update your modem to start enjoying them. It&#39;s on us.</b>'
, textline1: 'We&#39;ve noticed you have an older modem that can&#39;t keep up with faster Internet speeds now available in your area.'
, textline2: 'To start enjoying faster Internet, you can:'
, textline3: '<b>Buy from a retailer</b>'
, textline4: 'Before you make your purchase, visit <a href=\"#\" onClick="document.location.href=\'' + this.SYS_URL + '?dispatch=ackBulletinRedirectSleep&redirectName=dpe_mydeviceinfo_portal\'">mydeviceinfo.xfinity.com</a> to view a list of modems certified on our network.'
, textline5: '<b>Lease an XFINITY Gateway</b> (current lease fees would apply)'
, textline6: 'Visit <a href=\"#\" onClick="document.location.href=\'' + this.SYS_URL + '?dispatch=ackBulletinRedirectSleep&redirectName=dpe_device_equip_swap\'">customer.xfinity.com/equipmentSwap</a> to order a self-install kit or call <font color=#008EC9></br>1-855-242-2876</font>.'
, textline7: 'Questions? Find answers at <a href=\"#\" onClick="document.location.href=\'' + this.SYS_URL + '?dispatch=ackBulletinRedirectSleep&redirectName=dpe_trade_up\'">xfinity.com/tradeup</a>'
, textline8: 'Thank you for choosing XFINITY. You deserve the best, and we&#39;re committed to ensuring you receive all the benefits of your Internet service.'
, textline9: 'Equipment Update'
, privacypolicylink: '<a href="http://my.xfinity.com/privacy/" target="_new" style="color: #000000">PRIVACY POLICY</a>'
, termslink: '<a href="http://my.xfinity.com/terms/" target="_new" style="color: #000000">TERMS OF SERVICE</a>'
, closebulletin: '<a href=\"#\" onClick=\"javascript:_ComcastAlert.close_comcast_alert()\"><img src="' + image_url + 'close_button_78x78.png" height="28" width="28"/></a>'
, ackbulletin: '<a href=\"#\" onClick="document.location.href=\'' + this.SYS_URL + '?dispatch=ackBulletinRedirectSleep&redirectName=dpe_trade_up\'"><img src="' + image_url + 'trade_up_now_button_270x90.png" height="40" width="121"/></a>'
, analytics: '<img src="' + image_url + encodeURIComponent(comcastAlertAnalytics) + '?' + _ComcastAlert.comcastContentnoCache() + '">'
};
this.createWindow(winObj);
}
, createWindow: function(winObj){
var html = '<style type="text/css">';
html += '#comcast_content {width: ' + winObj.notice_width + '; height:' + winObj.notice_height + '; background:#ffffff; border: 1px solid #454545; position:absolute; top:150px; left:100px; zoom:1; z-index: 9999999999; opacity:0.99; filter:alpha(opacity=99);}';
html += '#comcast_content .header {height: 60px; width: ' + winObj.notice_width + '; background-color:#000000; repeat-x; z-index: 99999999;}';
html += '#comcast_content .content-wrapper {padding-left: 5px; padding-right: 5px; padding-bottom: 5px;}';
html += '#comcast_content .titletext1 {margin: 30px 20px 20px 30px; color: #303030; text-align: left; padding: 0; font: 22px/24px bold Helvetica, Geneva, sans-serif; font-weight: 200;}';
html += '#comcast_content .titletext2 {margin: 15px 20px 20px 30px; color: #303030; text-align: left; padding: 0; font: 16px/18px bold Helvetica, Geneva, sans-serif; font-weight: 200;}';
html += '#comcast_content .textcontent1 {margin: 15px 20px 0 30px; color: #303030; text-align: left; padding: 0; font: 15px/16px Helvetica, Geneva, sans-serif; font-weight: 200; line-height: 1.1;}';
html += '#comcast_content .textcontent2 {margin: 15px 20px 0 30px; color: #4C4C4C; text-align: left; padding: 0; font: 15px/16px Helvetica, Geneva, sans-serif; font-weight: 200; line-height: 1.2;}';
html += '#comcast_content .textcontent3 {margin: 10px 20px 0 40px; color: #000000; text-align: left; padding: 0; font: 15px/15px Helvetica, Geneva, sans-serif; font-weight: 200; line-height: 1.0;}';
html += '#comcast_content .privacystatement {display: inline-block; position:absolute; bottom:5px; left:20px; font: 12px/12px Helvetica, Geneva, sans-serif; font-weight: 200; text-align: bottom; white-space:nowrap;}';
html += '#comcast_content .privacystatement:link {color:#000000; text-decoration:none;}';
html += '#comcast_content .privacystatement:visited {color:#000000; text-decoration:none;}';
html += '#comcast_content .privacystatement:hover {color:#000000; text-decoration:underline;}';
html += '#comcast_content .termsofservice {display: inline-block; position:absolute; bottom:5px; left:150px; font: 12px/12px Helvetica, Geneva, sans-serif; font-weight: 200; text-align: bottom; white-space:nowrap;}';
html += '#comcast_content .termsofservice:link {color:#000000; text-decoration:none;}';
html += '#comcast_content .termsofservice:visited {color:#000000; text-decoration:none;}';
html += '#comcast_content .termsofservice:hover {color:#000000; text-decoration:underline;}';
html += '#comcast_content .comcastlogo {display: inline-block; position:absolute; bottom:5px; right:5px; margin: 0 0 0 0; height:50px; width:115px; z-index: 9999999999;}';
html += '#comcast_content .comcastanalytics {display: inline-block; position:absolute; bottom:3px; right:3px; height: 1px; width: 1px; z-index: -99999; margin: 0 0 0 0; }';
html += '#comcast_content .acknowledgebutton {display: inline-block; margin: 15px 20px 0 30px; color: #303030; text-align: left; padding: 0; font: 14px/16px Verdana, Geneva, sans-serif; line-height: 1.2; z-index: 9999999999; }';
html += '#comcast_content .xfinitylogo {display: inline-block; position:absolute; z-index: 9999999999; left:10px; top:5px; margin: 0 0 0 0; height:62px; width:110px;}';
html += '#comcast_content .closebn {display: inline-block; position:absolute; z-index: 9999999999; left:555px; top:16px; height:32px; width:32px; margin: 0 0 0 0;}';
html += '</style>';
html += '<div class="main-wrapper" id="comcast_content">';
html += '<div class="header" onmousedown="javascript:_ComcastAlert.dragStart(event,\'comcast_content\')">';
html += '</div>';
html += '<div class="content-wrapper">';
html += '<p class="xfinitylogo">';
html += winObj.xfinitylogo_url;
html += '</p>';
html += '<p class="closebn">';
html += winObj.closebulletin;
html += '</p>';
html += '<p class="titletext1">';
html += winObj.headertext1;
html += '</p>';
html += '<p class="titletext2">';
html += winObj.headertext2;
html += '</p>';
html += '<p class="textcontent1">';
html += winObj.textline1;
html += '</p>';
html += '<p class="textcontent1">';
html += winObj.textline2;
html += '</p>';
html += '<p class="textcontent3">';
html += winObj.textline3;
html += '</p>';
html += '<p class="textcontent3">';
html += winObj.textline4;
html += '</p>';
html += '<p class="textcontent3">';
html += winObj.textline5;
html += '</p>';
html += '<p class="textcontent3">';
html += winObj.textline6;
html += '</p>';
html += '<p class="textcontent1">';
html += winObj.textline7;
html += '</p>';
html += '<p class="textcontent1">';
html += winObj.textline8;
html += '</p>';
html += '<p class="textcontent2">';
html += winObj.textline9;
html += '</p>';
html += '<p class="privacystatement">';
html += winObj.privacypolicylink;
html += '</p>';
html += '<p class="termsofservice">';
html += winObj.termslink;
html += '</p>';
html += '<p class="comcastlogo">';
html += winObj.comcastlogo_url;
html += '</p>';
html += '<p class="comcastanalytics">';
html += winObj.analytics;
html += '</p>';
html += '</div>';
html += '</div>';
html += '</div>';
document.body.innerHTML = document.body.innerHTML + html;
}
// Function to Determine browser and version. Copyright 2001 by Mike Hall.
, checkBrowser: function() {
var ua, s, i;
var browser = {
isIE: false
, isNS: false
, version: null
};
ua = navigator.userAgent;
s = "MSIE";
if ((i = ua.indexOf(s)) >= 1) {
browser.isIE = true; browser.version = parseFloat(ua.substr(i + s.length));
}
s = "Netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
browser.isNS = true; browser.version = parseFloat(ua.substr(i + s.length));
}
s = "Gecko";
if ((i = ua.indexOf(s)) >= 0) {
browser.isNS = true; browser.version = 6.1;
}
return browser;
}
, dragStart: function(event, id) {
var browser1 = _ComcastAlert.browser;
var dragObj = _ComcastAlert.dragObj;
var el;
var x, y;
if (id) dragObj.elNode = document.getElementById(id);
else {
if (browser1.isIE) dragObj.elNode = window.event.srcElement;
if (browser1.isNS) dragObj.elNode = event.target;
if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode;
}
if (browser1.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
}
if (browser1.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}
dragObj.cursorStartX = x;
dragObj.cursorStartY = y;
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);
if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 100;
if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 50;
if (browser1.isIE) {
document.attachEvent("onmousemove", _ComcastAlert.dragGo);
document.attachEvent("onmouseup", _ComcastAlert.dragStop);
window.event.cancelBubble = true;
window.event.returnValue = false; }
if (browser1.isNS) {
document.addEventListener("mousemove", _ComcastAlert.dragGo, true);
document.addEventListener("mouseup", _ComcastAlert.dragStop, true);
event.preventDefault();
}
}
// End Function
, comcastContentnoCache: function() {
return Math.round(Math.random() * 96151252);
}
, dragGo: function(event) {
var browser1 = _ComcastAlert.browser;
var dragObj = _ComcastAlert.dragObj;
var x, y;
if (browser1.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
}
if (browser1.isNS) {
x = event.clientX + window.scrollX; y = event.clientY + window.scrollY;
}
dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px";
if (browser1.isIE) { window.event.cancelBubble = true; window.event.returnValue = false; }
if (browser1.isNS) event.preventDefault();
}
, dragStop: function(event) {
var browser1 = _ComcastAlert.browser;
if (browser1.isIE) {
document.detachEvent("onmousemove", _ComcastAlert.dragGo);
document.detachEvent("onmouseup", _ComcastAlert.dragStop);
}
if (browser1.isNS) {
document.removeEventListener("mousemove", _ComcastAlert.dragGo, true);
document.removeEventListener("mouseup", _ComcastAlert.dragStop, true);
}
}
, getXmlhttp: function(){
var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
this.xmlhttp = xmlhttp;
}
, checkBulletin: function(){
if(_ComcastAlert.comcastCheck==0) { return; }
var xmlhttp = _ComcastAlert.xmlhttp;
xmlhttp.open("GET", _ComcastAlert.SYS_URL+'?dispatch=checkBulletin',true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.responseText.indexOf('43a1028c-7d11-11de-b687-1f15c5ad6a13') == -1){
document.getElementById('comcast_content').style.display="none";
_ComcastAlert.comcastCheck = 0;
}
_ComcastAlert.comcastTimer = setTimeout("_ComcastAlert.checkBulletin()",5000);
};
};
xmlhttp.send(null);
}
, close_comcast_alert: function() {
document.getElementById('comcast_content').style.display = "none";
_ComcastAlert.sendAck();
}
, acknowledge: function() {
_ComcastAlert.sendAck();
document.getElementById('comcast_content').style.display = "none";
}
, sendAck: function(){
var xmlhttp = _ComcastAlert.xmlhttp;
xmlhttp.open("GET", _ComcastAlert.SYS_URL+'?dispatch=ackBulletin',true);
xmlhttp.send(null)
}
}
}());
_ComcastAlert.go();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment