Initial commit: Plex Auto Skip Chrome extension
This commit is contained in:
commit
0f1f2a309e
14 files changed
+1522
No files matched your search
@@ -0,0 +1,123 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const { loadContentScript, wait } = require("./helpers");
|
||||
|
||||
test("clicks a Skip Intro button on app.plex.tv", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Skip Intro</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1);
|
||||
});
|
||||
|
||||
test("clicks a Skip Credits button on app.plex.tv", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Skip Credits</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1);
|
||||
});
|
||||
|
||||
test("does nothing on a non-matching host", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://example.com/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Skip Intro</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 0);
|
||||
});
|
||||
|
||||
test("respects skipIntro:false toggle", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Skip Intro</button></body></html>`,
|
||||
settings: { skipIntro: false, skipCredits: true }
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 0);
|
||||
});
|
||||
|
||||
test("matches a custom configured URL by hostname", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "http://192.168.1.50:32400/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Skip Intro</button></body></html>`,
|
||||
settings: { plexUrl: "http://192.168.1.50:32400/web" }
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1);
|
||||
});
|
||||
|
||||
test("clicks a button added dynamically after page load", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body></body></html>`
|
||||
});
|
||||
|
||||
await wait(20);
|
||||
|
||||
const btn = window.document.createElement("button");
|
||||
btn.textContent = "Skip Intro";
|
||||
window.document.body.appendChild(btn);
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1);
|
||||
});
|
||||
|
||||
test("does not click an unrelated button", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button>Watch Now</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 0);
|
||||
});
|
||||
|
||||
test("real Plex markup: skip button includes a countdown suffix", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button><span>Skip Intro</span><span> 0:05</span></button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1);
|
||||
});
|
||||
|
||||
test("same DOM node reused for a later segment still gets clicked after cooldown", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button id="skip">Skip Intro</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 1, "first segment's skip button should be clicked");
|
||||
|
||||
const btn = window.document.getElementById("skip");
|
||||
btn.textContent = "";
|
||||
await wait(1700);
|
||||
|
||||
btn.textContent = "Skip Intro";
|
||||
await wait(50);
|
||||
assert.strictEqual(
|
||||
window.__clickedElements.length,
|
||||
2,
|
||||
"the same reused button should be clickable again after the cooldown"
|
||||
);
|
||||
});
|
||||
|
||||
test("does not click a hidden skip button", async () => {
|
||||
const { window } = loadContentScript({
|
||||
url: "https://app.plex.tv/web/index.html",
|
||||
html: `<!DOCTYPE html><html><body><button style="display:none">Skip Intro</button></body></html>`
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
assert.strictEqual(window.__clickedElements.length, 0);
|
||||
});
|
||||
Reference in new issue
Block a user