def InjectScript(content, content_type, script_to_inject):
  already_injected = False
  if content_type and content_type == 'text/html':
    already_injected = not content or script_to_inject in content
    if not already_injected:
      def InsertScriptAfter(matchobj):
        return '%s<script>%s</script>' % (matchobj.group(0), script_to_inject)

      content, is_injected = HEAD_RE.subn(InsertScriptAfter, content, 1)
      if not is_injected:
        content, is_injected = HTML_RE.subn(InsertScriptAfter, content, 1)
      if not is_injected:
        content, is_injected = DOCTYPE_RE.subn(InsertScriptAfter, content, 1)
      if not is_injected:
        content = '<script>%s</script>%s' % (script_to_inject, content)
        logging.warning('Inject at the very beginning, because no tag of '
                        '<head>, <html> or <!doctype html> is found.')
  return content, already_injected
Returns an iterator that can be used to access the objects within this
dataset/ETHPy150Open chromium/web-page-replay/script_injector.py/InjectScript--crossover with--dataset/ETHPy150Open rackspace/pyrax/pyrax/object_storage.py/ContainerManager.object_listing_iterator