edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Kevin Carhart <kevin@carhart.net>
To: Edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] [patch] [experimental] JS console patch
Date: Sun, 27 Sep 2015 23:00:52 -0700	[thread overview]
Message-ID: <20150827230052.kevin@carhart.net > (raw)

[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]

Here is my JS console code.
The commands I currently use are:
eg = enumerate globals
jex = javascript execute
ok = object keys - this is the JS function that eg runs,
so you can then call it in an expression like alert(ok(blah))

'eg' and 'jex' do not exactly roll off the tongue.
Could be changed into another command.
What my fingers are accustomed to is 'x' and 'y'

Here is some sample usage:
b http://pizza.com
[the page loads and the file sizes are returned]

eg
[voluminous output of about 100 objects and scalars, most having to do with google ads and god knows what]

jex alert('hello world')
hello world

jex var x = 5
?

jex alert(x)
5

jex alert(ok(document))
[voluminous output of enumeration of all objects under document, presently ending in our gc objects gc$$814, gc$$815, gc$$816]

jex for (blah in window) { alert(blah) }
[all of the objects in window, formatted with newlines]

jex alert(google_adk2_experiment)
N

[Well that's a relief!  Nice to know I am not a subject in an adk2 experiment.  All I wanted was some pizza...]


jex alert(google_jobrunner)
[object Object]

[google_jobrunner is an object.  I'm curious what's in it.]

jex alert(ok(google_jobrunner))
u,m,l,s,G


jex var jr = google_jobrunner
?

[Making an alias on the fly.]
jex alert(jr)
[object Object]

jex alert(jr.u)
[object Object]

jex alert(jr.m)
[object Window]

jex alert(jr.l)
0

jex alert(jr.s)
null

jex alert(jr.G)
0

[This scratches the surface .. function bodies can also be echoed and can be run using eval.  Get a sanity check on what you are debugging.. take 'typeof' different things to verify your assumptions... etc.]



[-- Attachment #2: /home/kevin/public_html/c7/edbrowse/jsconsole_20150927.patch --]
[-- Type: text/plain, Size: 1532 bytes --]

diff -Naur 1/src/buffers.c 2/src/buffers.c
--- 1/src/buffers.c	2015-09-27 11:06:51.000000000 -0700
+++ 2/src/buffers.c	2015-09-27 22:15:31.656778785 -0700
@@ -3554,6 +3554,44 @@
 		return true;
 	}
 
+	if (stringEqual(line, "eg")) {
+		static const char jsconsole1[] = "ok = Object.keys = Object.keys || (function () { \n\
+		var hasOwnProperty = Object.prototype.hasOwnProperty, \n\
+		hasDontEnumBug = !{toString:null}.propertyIsEnumerable(\"toString\"),\n\
+		DontEnums = [ \n\
+		'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', \n\
+		'isPrototypeOf', 'propertyIsEnumerable', 'constructor' \n\
+		], \n\
+		DontEnumsLength = DontEnums.length; \n\
+		return function (o) { \n\
+		if (typeof o != \"object\" && typeof o != \"function\" || o === null) \n\
+		throw new TypeError(\"Object.keys called on a non-object\");\n\
+		var result = []; \n\
+		for (var name in o) { \n\
+		if (hasOwnProperty.call(o, name)) \n\
+		result.push(name); \n\
+		} \n\
+		if (hasDontEnumBug) { \n\
+		for (var i = 0; i < DontEnumsLength; i++) { \n\
+		if (hasOwnProperty.call(o, DontEnums[i]))\n\
+		result.push(DontEnums[i]);\n\
+		}\n\
+		}\n\
+		return result; \n\
+		}; \n\
+		})(); \n\
+		alert(Object.keys(this)); \n\
+		";
+		javaParseExecute(cw->winobj, jsconsole1, "",1);
+		return true;
+	}
+
+	if (!strncmp(line, "jex ", 4)) {
+		char* routineonly = line + 4;
+		javaParseExecute(cw->winobj, routineonly, "",1);
+		return true;
+	}
+
 	if (stringEqual(line, "lna")) {
 		listNA ^= 1;
 		if (helpMessagesOn || debugLevel >= 1)

             reply	other threads:[~2015-09-28  5:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28  6:00 Kevin Carhart [this message]
2015-09-28  9:47 ` Karl Dahlke
     [not found] <5608d799.c539440a.54033.3b99SMTPIN_ADDED_BROKEN@mx.google.com>
2015-09-29  7:03 ` Adam Thompson
2015-09-29  9:04   ` Kevin Carhart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20150827230052.kevin@carhart.net ' \
    --to=kevin@carhart.net \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).