-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Chrome app to no longer require domain to be known.
Signed-off-by: Joachim Bauch <bauch@struktur.de>
- Loading branch information
Showing
4 changed files
with
249 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
/* global chrome */ | ||
|
||
/** | ||
* @author Joachim Bauch <bauch@struktur.de> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
(function() { | ||
|
||
sessionStorage.getScreenMediaJSExtensionId = chrome.runtime.id; | ||
var port = chrome.runtime.connect(); | ||
|
||
// Forward message from Nextcloud app to the extension. | ||
window.addEventListener('message', function(event) { | ||
var msg = event.data; | ||
if (event.source === window && !msg.answer) { | ||
port.postMessage(msg); | ||
} | ||
}); | ||
|
||
// Forward message from the extension to the Nextcloud app. | ||
port.onMessage.addListener(function(msg) { | ||
window.postMessage(msg, window.document.URL); | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* global chrome */ | ||
|
||
/** | ||
* @author Joachim Bauch <bauch@struktur.de> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
(function(document) { | ||
|
||
function hasClass(element, cls) { | ||
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1; | ||
} | ||
|
||
// Only add extension if the page is running the Nextcloud app. | ||
var nc = document.getElementById('app'); | ||
if (!nc || !hasClass(nc, 'nc-enable-screensharing-extension')) { | ||
return; | ||
} | ||
|
||
var extension = nc.getAttribute('data-chromExtensionData'); | ||
if (extension) { | ||
try { | ||
extension = JSON.parse(extension); | ||
} catch (e) { | ||
return; | ||
} | ||
} | ||
|
||
console.log('Detected Nextcloud video calls app.'); | ||
var msg = { | ||
type: 'init-nc-screensharing', | ||
data: { | ||
extension: extension || null | ||
} | ||
}; | ||
|
||
chrome.runtime.sendMessage(null, msg, null, function(data) { | ||
console.log('Initialized extension', data); | ||
nc.setAttribute('data-chromExtensionData', JSON.stringify(data)); | ||
}); | ||
|
||
}(document)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
{ | ||
"name": "Nextcloud Screensharing", | ||
"description": "Screensharing utility for the Nextcloud video calls app.", | ||
"author": "Joachim Bauch <bauch@struktur.de>", | ||
"homepage_url": "https://nextcloud.com", | ||
"version": "0.0.1", | ||
"manifest_version": 2, | ||
"minimum_chrome_version": "34", | ||
"icons": { | ||
}, | ||
"permissions": [ | ||
"desktopCapture" | ||
"tabs", | ||
"desktopCapture", | ||
"https://*/*" | ||
], | ||
"background": { | ||
"scripts": ["background.js"] | ||
"scripts": ["background.js"], | ||
"persistent": false | ||
}, | ||
"content_scripts": [ { | ||
"js": [ "content.js" ], | ||
"matches": [ "https://replace-with-your-hostname/*" ] | ||
}], | ||
"externally_connectable": { | ||
"matches": [ | ||
"https://replace-with-your-hostname/*" | ||
] | ||
} | ||
"content_scripts": [ | ||
{ | ||
"js": ["detector.js"], | ||
"matches": ["https://*/*"], | ||
"run_at": "document_end", | ||
"all_frames": true | ||
} | ||
] | ||
} |