Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
429 stars 100 forks source link

Make screensharing extension integration customizable #230

Open zdila opened 7 years ago

zdila commented 7 years ago

In our application we use our custom Chrome extension to provide screensharing. Now we must patch adapterjs sources to not to use universal iframe with detectRTC.html. Would you accept a pull request which would make it configurable?

johache commented 7 years ago

That shouldn't be an issue. You may add links to the Chrome/FF extension in source/pluginInfo.js, and use them in source/adapter.screensharing.js. After that, you should be able to easily override the content of the dictionary by defining it before requiring AJS (eventually we might move to a config step, but not right now)

zdila commented 7 years ago

Thanks for mentioning pluginInfo.

Still in our case we use no iframe and logic simillar to detectRTC.html is directly in our main JS.

Currently we use following regexps to patch AdapterJS code on Webpack build:

// see https://github.com/Temasys/AdapterJS/issues/230
        replace: /\{\s*var iframe\s*=\s*document\.createElement\(/,
        with: '{return;var iframe=document.createElement('

        replace: /(var )?postFrameMessage/,
        with: 'window.postFrameMessage'

        replace: /(var |,)onIFrameCallback\s*=/,
        with: ';window.onIFrameCallback='

        replace: /\bmessage\b/g,
        with: 'xxxx_message'

        replace: 'https://addons.mozilla.org/en-US/firefox/addon/skylink-webrtc-tools/',
        with: 'https://addons.mozilla.org/en-GB/firefox/addon/someapp-screen-sharing/'

// see https://github.com/Temasys/AdapterJS/issues/228
        replace: '"PermissionDeniedError", "SecurityError"|\'PermissionDeniedError\',\'SecurityError\'',
        with: '"NotAllowedError"'

// see https://github.com/Temasys/AdapterJS/issues/229
        replace: 'http:\/\/',
        with: `https://`
simonemazzoni commented 6 years ago

Hello, I think this issue is still present! I'm trying to use my custom extension (which is similar to the official Skylink one) but I got errors in Chrome because even if I replace extensionInfo.chrome.iframeLink param with the address of my detectRTC.html version, the iframe is appended before the redefinition of the variable and so https://cdn.temasys.com.sg/skylink/extensions/detectRTC.html is still loaded as iframeLink, but that page contains the extensionId of the skylink extension, and nothing works.

i guess it would be useful to have a sort of init method where to possibly specify custom configurations, or a method to update such configurations.

Notice that I am using adapter.screenshare.min.js from NPM imported as ES6 module in my app code.