Browse Source

Added files

master
Stephen Downward 2 years ago
parent
commit
3ddbf9b757
5 changed files with 84 additions and 1 deletions
  1. +11
    -1
      README.md
  2. BIN
      chrome-engine-packed.crx
  3. BIN
      icon.png
  4. +54
    -0
      main.js
  5. +19
    -0
      manifest.json

+ 11
- 1
README.md View File

@@ -1,3 +1,13 @@
# jerkface-chrome

This is a chrome extension I wrote to prank some friends. Every day, it lowers playback rate on YouTube by 1%, until it hits a target speed of 70% - 30 days later. It has the Chrome icon and calls itself "Chrome Engine" as a disguise.
This is a chrome extension I wrote to prank some friends. Every day, it lowers playback rate on YouTube by 1%, until it hits a target speed of 70% - 30 days later. It has the Chrome icon and calls itself "Chrome Engine" as a disguise.

Speed controls still work as intended. There's also some slightly fancy mechanics under the hood - Check out the comments in the source code!

## To install:

1. Download "chrome-engine-packed.crx" from this repository

2. Navigate to chrome://extensions/

3. Drag and drop the downloaded file there, it will install

BIN
chrome-engine-packed.crx View File


BIN
icon.png View File

Before After
Width: 2000  |  Height: 2000  |  Size: 404 KiB

+ 54
- 0
main.js View File

@@ -0,0 +1,54 @@
var videoElement = document.getElementsByClassName('video-stream')[0];

var speedModifier = 1.0;
var disableRateChangeEventListener = false; //Prevents event listener from triggering itself

//Using Chrome sync storage.
//The speed difference will be there on
//all of their devices, as long as they're signed in
//and using Chrome.
chrome.storage.sync.get(["lastRateChange"], function(items) {
if(items.lastRateChange == null) {
var now = new Date();
now.setHours(24, 0, 0, 0);
var rateChangeObj = {
"timestamp": +now,
"value": 1.00 //Gives a day of buffer time
};
chrome.storage.sync.set({"lastRateChange": rateChangeObj});
}
else {
speedModifier = items.lastRateChange.value;
//Speed loses 0.01, even if multiple days have passed.
//If the user goes on vacation or doesn't visit YouTube for a few days,
//they won't lose a few percent speed, which could be noticeable.
if(speedModifier > 0.7 && new Date() > new Date(items.lastRateChange.timestamp)) { //It's the next day at minimum
speedModifier -= 0.01;
var now = new Date();
now.setHours(24, 0, 0, 0);
var rateChangeObj = {
"timestamp": +now,
"value": speedModifier
};
chrome.storage.sync.set({"lastRateChange": rateChangeObj});
}
disableRateChangeEventListener = true;
videoElement.playbackRate *= speedModifier;
}
});

videoElement.addEventListener('ratechange', function() { //Ensures speed controls still work
if(!disableRateChangeEventListener) {
disableRateChangeEventListener = true;
var hasSound = videoElement.playbackRate >= 0.5;
videoElement.playbackRate *= speedModifier;
//Sound playback doesn't work if the video is playing slower than half speed.
//This could raise some alarms if sound stops even when the user selects 0.5x speed.
//So, if sound should be enabled, this adds a hard cap of 0.5x.
//If the user selects 0.25, there's no sound anyway, so there's no reason to
//enable this cap.
if(hasSound && videoElement.playbackRate < 0.5) videoElement.playbackRate = 0.5;
} else {
disableRateChangeEventListener = false;
}
});

+ 19
- 0
manifest.json View File

@@ -0,0 +1,19 @@
{
"manifest_version": 2,

"name": "Chrome Engine",
"description": "This extension serves as the main backbone for the Google Chrome webbrowser. Don't mess with this if you're not a developer!",
"version": "59.0.3071",

"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"activeTab",
"storage"
],
"content_scripts": [{
"matches": ["https://www.youtube.com/*"],
"js": ["main.js"]
}]
}

Loading…
Cancel
Save