Skip to content

GuillaumeMCK/BadApple-On-Github-Activity-Graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BadApple-On-Github-Activity-Graph

A single line of code to play the iconic Bad Apple!! animation on your GitHub activity graph!

Bad Apple!! on Github Activity Graph

How to Run It

Run Locally

  1. Clone the repository:
git clone https://github.com/GuillaumeMCK/BadApple-On-Github-Activity-Graph.git
  1. Open the index.html file located in the src directory.

Run on Your GitHub Profile

  1. Copy the minified script shown below (or download it from the raw file here.
let t,e;const a=document.querySelector(".js-activity-overview-graph"),r=a.querySelector("path"),n=a.querySelectorAll("ellipse");let c=0,i=!1;const o=1e3/30;async function l(){if(!l.cachedData){let t=await fetch("https://raw.githubusercontent.com/GuillaumeMCK/BadApple-On-Github-Activity-Graph/main/src/data/frames.json");if(!t.ok)throw Error(t.status);l.cachedData=await t.json()}return l.cachedData}async function u(){if(!u.cachedData){let t=await fetch("https://raw.githubusercontent.com/GuillaumeMCK/BadApple-On-Github-Activity-Graph/main/src/data/track.ogg");if(!t.ok)throw Error(t.status);u.cachedData=await t.arrayBuffer()}return u.cachedData}async function s(){if(i)return;i=!0;let[s,h]=await Promise.all([u(),l()]);(function(){let t=a.querySelector("g").getCTM().inverse();r.setAttribute("transform",`translate(${t.e+8}, ${t.f})`),r.setAttribute("stroke-width",".5"),n.forEach(t=>t.style.display="none")})(),(await d(s)).start(),e=setInterval(()=>{var n;n=h[c],r.setAttribute("d",n.polygons.map(t=>`M${t.join(" L")} Z`).join(" ")),0==(c=(c+1)%h.length)&&(e&&(clearInterval(e),e=null),t&&a.parentNode&&a.parentNode.replaceChild(t.cloneNode(!0),a),i=!1,c=0)},o)}async function d(t,e=.25){let a=new window.AudioContext,r=await a.decodeAudioData(t),n=a.createBufferSource();n.buffer=r;let c=a.createGain();return c.gain.value=e,n.connect(c),c.connect(a.destination),n}t||(t=a.cloneNode(!0)),s();

SHA-256: d69d03b206587d2705dc85a2d6f70022362fbc7689526a09326e60e31f808a20

  1. Go to your GitHub profile page and open the browser’s developer console (Ctrl + Shift + I or F12).
  2. Paste the script into the console and press Enter to start the animation.

Credits

Audio & Animation Data: Bad Apple!!