Skip to content

Commit

Permalink
Merge branch 'chrome-extension-tidy-up'
Browse files Browse the repository at this point in the history
  • Loading branch information
madman-bob committed Sep 15, 2017
2 parents 4ad0fc6 + 7826ff2 commit 6a908ac
Show file tree
Hide file tree
Showing 20 changed files with 9,031 additions and 8,697 deletions.
18 changes: 18 additions & 0 deletions POV Cam/arrow-navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function initArrowNavigation(nextPageLink) {
document.onkeydown = function (e) {
if (e.keyCode == 39) {
// Press right
if (nextPageLink) {
nextPageLink.click();
return false;
} else {
return true;
}
} else if (e.keyCode == 37) {
// Press left
history.back();
return false;
}
return true;
};
}
103 changes: 103 additions & 0 deletions POV Cam/flash-controls/flash-controls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Modified from the bookmarklet made by squarefree
// https://www.squarefree.com/bookmarklets/flash.html

// PercentLoaded
// IsPlaying
// Rewind
// GetVariable, SetVariable

function initFlashControls() {
var flashPanels = document.embeds;
if (
(flashPanels.length > (document.location.pathname == "/trickster.php" || document.location.pathname == "/index_hscrollb.php"))
&& (flashLengths[pageNo] != -1)
) {
var flashPanel = flashPanels[flashPanels.length - 1];
addFlashControls(flashPanel);
}
}

function addFlashControls(flashPanel) {
// MSPA uses inconsistent subdomaining
// Convert flash to appropriate subdomain
var i = flashPanel.src.indexOf("mspaintadventures.com") + 21;
if ((i != 20) && (flashPanel.src.substr(0, i) != document.location.origin)) {
var tempflash = flashPanel.cloneNode();
tempflash.src = document.location.origin + flashPanel.src.slice(i);
flashPanel.insertAdjacentElement("afterEnd", tempflash);
flashPanel.parentElement.removeChild(flashPanel);
flashPanel = tempflash;
}

var controlsDiv = document.createElement("div");
flashPanel.insertAdjacentElement("afterEnd", controlsDiv);

var table = document.createElement("table");
table.width = "650px";
controlsDiv.appendChild(table);

var row = table.insertRow(-1);

var pauseButton = document.createElement("button");
pauseButton.innerText = "Pause";

var buttonCell = row.insertCell(-1);
buttonCell.appendChild(pauseButton);
pauseButton.onclick = togglePause;

var sliderCell = row.insertCell(-1);
sliderCell.style.width = "100%";
var slider = document.createElement("input");
slider.style.width = "100%";
slider.type = "range";
slider.min = 0;
if (pageNo in flashLengths) {
slider.max = flashLengths[pageNo];
} else {
slider.max = 0; // Actually set during first run of update
}
slider.value = 0;
sliderCell.appendChild(slider);
var sliderWidth;
var paused = false;
var dragging = false;
slider.oninput = function () {
if (slider.value == flashLengths[pageNo]) {
flashPanel.GotoFrame(slider.value - 1);
} else {
flashPanel.GotoFrame(slider.value);
}
};
slider.onchange = function () {
if (paused) {
flashPanel.StopPlay();
} else {
flashPanel.Play();
}
};

window.setInterval(updateSliderValue, 33);

function togglePause() {
if (flashPanel.Play) {
paused = !paused;
if (paused) {
pauseButton.style.borderStyle = "inset";
flashPanel.StopPlay();
} else {
pauseButton.style.borderStyle = "";
flashPanel.Play();
}
}
}

function updateSliderValue() {
if (flashPanel.CurrentFrame) {
if (flashPanel.CurrentFrame() > slider.max) {
// Not the most efficient of checks, but it works in a lot of edge cases
slider.max = flashPanel.TotalFrames();
}
slider.value = flashPanel.CurrentFrame();
}
}
}
Loading

0 comments on commit 6a908ac

Please sign in to comment.