Added optout

This commit is contained in:
JustinCB 2020-05-02 12:05:58 -04:00 committed by Mike Welsh
parent 7413732834
commit 75f398cf16
1 changed files with 16 additions and 1 deletions

View File

@ -14,7 +14,16 @@
* unintentionally. * unintentionally.
* 2. The ability to load extension resources such as .wasm files * 2. The ability to load extension resources such as .wasm files
*/ */
let page_optout = document.getElementsByTagName("html")[0].dataset.ruffleOptout !== undefined; let page_optout = document.documentElement.hasAttribute("data-ruffle-optout");
try {
if ((!page_optout)&&window.top&&window.top.document&&window.top.document.documentElement) {
/* In case the opting out page uses iframes */
page_optout = window.top.document.documentElement.hasAttribute("data-ruffle-optout");
}
}
catch (e) {
console.log("Unable to check top-level optout: " + e.message);
}
let obfuscated_event_prefix = "rufEvent" + Math.floor(Math.random() * 100000000000); let obfuscated_event_prefix = "rufEvent" + Math.floor(Math.random() * 100000000000);
let ext_path = ""; let ext_path = "";
if (chrome && chrome.extension && chrome.extension.getURL) { if (chrome && chrome.extension && chrome.extension.getURL) {
@ -30,11 +39,17 @@ if (!(page_optout||window.RufflePlayer)) {
'(function(){class RuffleMimeType{constructor(a,b,c){this.type=a,this.description=b,this.suffixes=c}}class RuffleMimeTypeArray{constructor(a){this.__mimetypes=[],this.__named_mimetypes={};for(let b of a)this.install(b)}install(a){let b=this.__mimetypes.length;this.__mimetypes.push(a),this.__named_mimetypes[a.type]=a,this[a.type]=a,this[b]=a}item(a){return this.__mimetypes[a]}namedItem(a){return this.__named_mimetypes[a]}get length(){return this.__mimetypes.length}}class RufflePlugin extends RuffleMimeTypeArray{constructor(a,b,c,d){super(d),this.name=a,this.description=b,this.filename=c}install(a){a.enabledPlugin||(a.enabledPlugin=this),super.install(a)}}class RufflePluginArray{constructor(a){this.__plugins=[],this.__named_plugins={};for(let b of a)this.install(b)}install(a){let b=this.__plugins.length;this.__plugins.push(a),this.__named_plugins[a.name]=a,this[a.name]=a,this[b]=a}item(a){return this.__plugins[a]}namedItem(a){return this.__named_plugins[a]}get length(){return this.__plugins.length}}const FLASH_PLUGIN=new RufflePlugin("Shockwave Flash","Shockwave Flash 32.0 r0","ruffle.js",[new RuffleMimeType("application/futuresplash","Shockwave Flash","spl"),new RuffleMimeType("application/x-shockwave-flash","Shockwave Flash","swf"),new RuffleMimeType("application/x-shockwave-flash2-preview","Shockwave Flash","swf"),new RuffleMimeType("application/vnd.adobe.flash-movie","Shockwave Flash","swf")]);function install_plugin(a){console.log("installing polyfill");navigator.plugins.install||Object.defineProperty(navigator,"plugins",{value:new RufflePluginArray(navigator.plugins),writable:!1}),navigator.plugins.install(a),0<a.length&&!navigator.mimeTypes.install&&Object.defineProperty(navigator,"mimeTypes",{value:new RuffleMimeTypeArray(navigator.mimeTypes),writable:!1});for(var b=0;b<a.length;b+=1)navigator.mimeTypes.install(a[b])}install_plugin(FLASH_PLUGIN);})();'; '(function(){class RuffleMimeType{constructor(a,b,c){this.type=a,this.description=b,this.suffixes=c}}class RuffleMimeTypeArray{constructor(a){this.__mimetypes=[],this.__named_mimetypes={};for(let b of a)this.install(b)}install(a){let b=this.__mimetypes.length;this.__mimetypes.push(a),this.__named_mimetypes[a.type]=a,this[a.type]=a,this[b]=a}item(a){return this.__mimetypes[a]}namedItem(a){return this.__named_mimetypes[a]}get length(){return this.__mimetypes.length}}class RufflePlugin extends RuffleMimeTypeArray{constructor(a,b,c,d){super(d),this.name=a,this.description=b,this.filename=c}install(a){a.enabledPlugin||(a.enabledPlugin=this),super.install(a)}}class RufflePluginArray{constructor(a){this.__plugins=[],this.__named_plugins={};for(let b of a)this.install(b)}install(a){let b=this.__plugins.length;this.__plugins.push(a),this.__named_plugins[a.name]=a,this[a.name]=a,this[b]=a}item(a){return this.__plugins[a]}namedItem(a){return this.__named_plugins[a]}get length(){return this.__plugins.length}}const FLASH_PLUGIN=new RufflePlugin("Shockwave Flash","Shockwave Flash 32.0 r0","ruffle.js",[new RuffleMimeType("application/futuresplash","Shockwave Flash","spl"),new RuffleMimeType("application/x-shockwave-flash","Shockwave Flash","swf"),new RuffleMimeType("application/x-shockwave-flash2-preview","Shockwave Flash","swf"),new RuffleMimeType("application/vnd.adobe.flash-movie","Shockwave Flash","swf")]);function install_plugin(a){console.log("installing polyfill");navigator.plugins.install||Object.defineProperty(navigator,"plugins",{value:new RufflePluginArray(navigator.plugins),writable:!1}),navigator.plugins.install(a),0<a.length&&!navigator.mimeTypes.install&&Object.defineProperty(navigator,"mimeTypes",{value:new RuffleMimeTypeArray(navigator.mimeTypes),writable:!1});for(var b=0;b<a.length;b+=1)navigator.mimeTypes.install(a[b])}install_plugin(FLASH_PLUGIN);})();';
let scriptelem = document.createElement("script"); let scriptelem = document.createElement("script");
setup_scriptelem.innerHTML = setup_src; setup_scriptelem.innerHTML = setup_src;
/* The setup_scriptelem sets runtime_path & obfusticated_event_prefix *
* and runs the plugin polyfill, which must run before any flash *
* detection scripts. */
(document.head || document.documentElement).appendChild(setup_scriptelem); (document.head || document.documentElement).appendChild(setup_scriptelem);
window.RufflePlayer = {}; window.RufflePlayer = {};
window.RufflePlayer.config = { window.RufflePlayer.config = {
"public_path": ext_path + "dist/", "public_path": ext_path + "dist/",
"polyfills": ["static-content", "dynamic-content"] "polyfills": ["static-content", "dynamic-content"]
/* We only want "static-content" & "dynamic-content" because we *
* inject the plugin polyfill above & use all_frames in *
* manifest.json for (i)frames. */
}; };
scriptelem.src = ext_path + "dist/ruffle.js"; scriptelem.src = ext_path + "dist/ruffle.js";
(document.head || document.documentElement).appendChild(scriptelem); (document.head || document.documentElement).appendChild(scriptelem);