getAllScripts method

List<String> getAllScripts()

Returns the list of all data enclosed in script tags of the document.

Implementation

List<String> getAllScripts() {
  // The _document should not be null (loadWebPage must be called before getAllScripts).
  assert(_document != null);

  // Quering the list of elements by tag names.
  var scripts = _document!.getElementsByTagName('script');
  var result = <String>[];

  // Looping in all script tags of the document.
  for (var script in scripts) {
    /// Adds the data enclosed in script tags
    /// ex. if document contains <script> var a = 3; </script>
    /// var a = 3; will be added to result.
    result.add(script.text);
  }
  return result;
}