diff --git a/content/buffers.js b/content/buffers.js index 492195bb..a9069c23 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -283,6 +283,13 @@ vimperator.Buffer = function () //{{{ return window.content.document.title; }, + // quick function to get elements inside the document reliably + // argument "args" is something like: @id='myid' or @type='text' (don't forget the quoted around myid) + element: function (args, index) + { + return vimperator.buffer.evaluateXPath("//*[" + (args || "") + "]").snapshotItem(index || 0) + }, + // returns an XPathResult object evaluateXPath: function (expression, doc, elem, asIterator) { diff --git a/content/events.js b/content/events.js index 25e020f6..78b7c886 100644 --- a/content/events.js +++ b/content/events.js @@ -271,7 +271,8 @@ vimperator.Events = function () //{{{ for (var now = then; now - then < ms; now = new Date().getTime()) { mainThread.processNextEvent(true); - dump("waited: " + (now - then) + " ms\n"); + if ((now -then) % 1000 < 10) + dump("waited: " + (now - then) + " ms\n"); if (vimperator.buffer.loaded > 0) break; diff --git a/content/vimperator.js b/content/vimperator.js index b46880a4..627def26 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -621,6 +621,7 @@ const vimperator = (function () //{{{ vimperator.completion = vimperator.Completion(); vimperator.log("All modules loaded", 3); + // we define some shortcuts to functions which are used often vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); }; vimperator.echoerr = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); };