

def GetInjectScript(scripts):
    'Loads |scripts| from disk and returns a string of their content.'
    lines = []
    if scripts:
        if (not isinstance(scripts, list)):
            scripts = scripts.split(',')
        for script in scripts:
            if os.path.exists(script):
                with open(script) as f:
                    lines.extend(f.read())
            elif util.resource_exists(script):
                lines.extend(util.resource_string(script))
            else:
                raise Exception('Script does not exist: %s', script)

    def MinifyScript(script):
        "Remove C-style comments and line breaks from script.\n    Note: statements must be ';' terminated, and not depending on newline"
        MULTILINE_COMMENT_RE = re.compile('/\\*.*?\\*/', (re.DOTALL | re.MULTILINE))
        SINGLELINE_COMMENT_RE = re.compile('//.*', re.MULTILINE)
        script = re.sub(MULTILINE_COMMENT_RE, '', script)
        script = re.sub(SINGLELINE_COMMENT_RE, '', script)
        script = script.translate(None, '\r\n')
        return script
    return MinifyScript(''.join(lines))

dataset/ETHPy150Open chromium/web-page-replay/script_injector.py GetInjectScript/original