scraper.js 790 B

123456789101112131415161718192021222324252627
  1. /* vim:fileencoding=utf-8
  2. *
  3. * Copyright (C) 2022 Kovid Goyal <kovid at kovidgoyal.net>
  4. *
  5. * Distributed under terms of the GPLv3 license
  6. */
  7. (function() {
  8. "use strict";
  9. function send_msg(data) {
  10. var token = 'TOKEN';
  11. var msg = token + ' ' + JSON.stringify(data);
  12. console.log(msg);
  13. }
  14. function debug() {
  15. var args = Array.prototype.slice.call(arguments);
  16. var text = args.join(' ');
  17. send_msg({type: 'print', text: text});
  18. }
  19. if (document.location && document.location.href && !document.location.href.startsWith('chrome-error:') && !document.location.href.startsWith('about:')) {
  20. send_msg({type: 'domready', url: document.location.href, html: new XMLSerializer().serializeToString(document)});
  21. }
  22. })();