From 6db100ac6aab7d88e28f439393a511fa46035794 Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Mon, 30 Sep 2019 17:49:32 -0500 Subject: [PATCH] Fix #331, remove old YouTube code --- extension/intents/playing/pauseMedia.js | 18 -------- extension/intents/playing/playMedia.js | 18 -------- extension/intents/playing/playing.js | 56 ------------------------- 3 files changed, 92 deletions(-) delete mode 100644 extension/intents/playing/pauseMedia.js delete mode 100644 extension/intents/playing/playMedia.js delete mode 100644 extension/intents/playing/playing.js diff --git a/extension/intents/playing/pauseMedia.js b/extension/intents/playing/pauseMedia.js deleted file mode 100644 index 133b96b45..000000000 --- a/extension/intents/playing/pauseMedia.js +++ /dev/null @@ -1,18 +0,0 @@ -// pauseMedia.js - -(function() { - const videos = document.getElementsByTagName("video"); - const audios = document.getElementsByTagName("audio"); - - const firstMediaItem = videos.item(0) || audios.item(0); - console.log("the first media item is this"); - console.log(firstMediaItem); - if (firstMediaItem) { - // TODO: this is probably intended to return "playing?" but instead it's resolving a promise that is thrown away - firstMediaItem.pause().then(result => { - console.log("playing?"); - }); - } else { - console.log("no media found"); - } -})(); diff --git a/extension/intents/playing/playMedia.js b/extension/intents/playing/playMedia.js deleted file mode 100644 index 71a54271f..000000000 --- a/extension/intents/playing/playMedia.js +++ /dev/null @@ -1,18 +0,0 @@ -// playMedia.js - -(function() { - const videos = document.getElementsByTagName("video"); - const audios = document.getElementsByTagName("audio"); - - const firstMediaItem = videos.item(0) || audios.item(0); - console.log("the first media item is this"); - console.log(firstMediaItem); - if (firstMediaItem) { - // TODO: this is probably intended to return "playing?" but instead it's resolving a promise that is thrown away - firstMediaItem.play().then(result => { - console.log("playing?"); - }); - } else { - console.log("no media found"); - } -})(); diff --git a/extension/intents/playing/playing.js b/extension/intents/playing/playing.js deleted file mode 100644 index b7e58cd66..000000000 --- a/extension/intents/playing/playing.js +++ /dev/null @@ -1,56 +0,0 @@ -/* globals searching, log */ - -this.intents.playing = (function() { - this.intentRunner.registerIntent({ - name: "playing.play", - examples: [ - "Play Green Day", - "Play yesterday's Daily Show", - "Play Old Town Road", - ], - match: ` - play [query] - unpause - `, - async run(context) { - let playerTab; - if (context.slots.query) { - // Multi-part execution task: will do magical IFL Google Search, then execute play once the page loads - let query = context.slots.query; - log.debug('Adding "youtube" to query:', query); - if (!/youtube/i.test(query)) { - query += " youtube"; - } - const googleQueryURL = searching.googleSearchUrl(query, true); - playerTab = await context.createTab({ - url: googleQueryURL, - }); - } else { - playerTab = (await browser.tabs.query({ active: true }))[0]; - } - - // get video content for the current tab - setTimeout(async () => { - await browser.tabs.executeScript(playerTab.id, { - file: "/intents/playing/playMedia.js", - }); - // TODO: poll for playing, instead of timeout - }, 3000); - }, - }); - - this.intentRunner.registerIntent({ - name: "playing.pause", - examples: ["pause"], - match: ` - pause - `, - async run(desc) { - const currentTab = (await browser.tabs.query({ active: true }))[0]; - // get video content for the current tab - await browser.tabs.executeScript(currentTab.id, { - file: "/intents/playing/pauseMedia.js", - }); - }, - }); -})();