Skip to content

Commit

Permalink
add workaround for #1, release v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
grmat committed May 31, 2018
1 parent de7d85d commit fd2284b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "Play media on current URL in external application.",
"manifest_version": 2,
"name": "play-with",
"version": "1.3.1",
"version": "1.3.2",
"default_locale": "en",

"background": {
Expand All @@ -14,7 +14,7 @@
"js": ["play.js"]
}],

"permissions": ["activeTab", "contextMenus"],
"permissions": ["activeTab", "contextMenus", "storage"],

"browser_action": {
"browser_style": true,
Expand Down
30 changes: 27 additions & 3 deletions src/play.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
/*
* Workaround for issue #1/upstream bug 1465458
*/
var firstRunElapsed;

function onError(error) {
console.log(`Error: ${error}`);
firstRunElapsed = false;
}

function onGot(item) {
firstRunElapsed = item.firstRunElapsed || false;
}

var getting = browser.storage.local.get(["firstRunElapsed"]);
getting.then(onGot, onError);

/*
* Create a M3U playlist file, paste the passed URL into it and download it.
*/
function download(request, sender, sendResponse) {
var filename = "stream.m3u";
var content = "#EXTM3U\n" + request.url;
var element = document.createElement('a');
var mime = 'video/x-mpegurl';
// this prevents FF from remembering to "always open with..."
//element.setAttribute('download', filename);

if (!firstRunElapsed) {
// this prevents FF from remembering to "always open with..."
var filename = "stream.m3u";
element.setAttribute('download', filename);
browser.storage.local.set({
firstRunElapsed: true
});
}

element.setAttribute('href', 'data:' + mime + ';charset=utf-8,' + encodeURIComponent(content));
element.style.display = 'none';
document.body.appendChild(element);
Expand Down

0 comments on commit fd2284b

Please sign in to comment.