Bad Dragon White/Blank Page Fix

Workaround for the white page & blank page bugs on Bad Dragon.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Bad Dragon White/Blank Page Fix
// @namespace    https://greasyfork.org/en/scripts/432440-bad-dragon-white-blank-page-fix
// @version      0.1.5
// @description  Workaround for the white page & blank page bugs on Bad Dragon.
// @author       tikutaro
// @match        *://bad-dragon.com/*
// @icon         https://www.google.com/s2/favicons?domain=bad-dragon.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const exp = /.*\:\/\/.*\.cloudfront\.net\/(app|media)-.*\.js/;
    const scripts = [];
    for (const child of document.getElementsByTagName('script')) {
        if (exp.test(child.src)) {
            scripts.push(child.src);
        }
    }
    const head = document.getElementsByTagName('head')[0];
    for (const url of scripts) {
        const tag = document.createElement('script');
        tag.setAttribute('type', 'text/javascript');
        tag.setAttribute('src', url);
        head.appendChild(tag);
    }
})();