edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] [patch] [experimental] JS console patch
@ 2015-09-28  6:00 Kevin Carhart
  2015-09-28  9:47 ` Karl Dahlke
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Carhart @ 2015-09-28  6:00 UTC (permalink / raw)
  To: Edbrowse-dev

[-- 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)

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <5608d799.c539440a.54033.3b99SMTPIN_ADDED_BROKEN@mx.google.com>]

end of thread, other threads:[~2015-09-29  9:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-28  6:00 [Edbrowse-dev] [patch] [experimental] JS console patch Kevin Carhart
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

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).