DOM APIs in V8 shell - dom

I have compiled SHELL from standalone Google's V8 javascript engine to run javascript. It works fine until I give a javascript that has DOM API in it. With DOM APIs it gives syntax error. Is there any library that should be included to get this worked?

The stand-alone shell doesn't have the DOM (Document Object Model), since it's not running in a browser that provides the document and DOM implementation.
If you just want to try some DOM code, you might be able to use something like https://github.com/Raynos/DOM-shim to simulate a DOM. You obviously won't have a real page and it won't be visible anywhere, but it might work for testing purposes.

Related

In the Common Lisp ecossystem of libraries, how to get the active element of the DOM using Clss and/or Plump instead of Parenscript?

Using javascript in the browser's console (firefox), I can do:
document.activeElement.placeholder
If the mouse cursor is in the StackOverflow search bar, the code above returns:
"Search…"
I can achieve the same using Parenscript with:
(ps:chain document active-element placeholder)
Is it possible to achieve the same output using CL Plump (manual) and/or Clss (manual) instead of Parenscript?
If so, how to do it?
I have tried finding this on the documentation references above but I could not find it. I am new to CL, though. Maybe I missed something.
Thanks.
When using Parenscript you are using the browser engine through JavaScript. The browser has a concept of user interaction, such as focus, on top of the model representing the document itself.
Plump and CLSS are not browser engines. They only have an object model of the HTML document they have parsed. They do not model anything like user interaction, so they also do not have something like the »active element«.

Perl: Parsing AJAX loaded content

This is an age-old question regarding perl web scrapers after Web 2.0; they simply cannot parse dynamically loaded pages because they need some sort of JavaScript engine in order to render the page. This issue is much more involved than simply rendering JavaScript, since Perl would also have to be able to manage and maintain the DOM.
It seems WWW::Selenium and WWW::Mechanize::Firefox is able to accomplish this by utilizing FireFox (or other browsers) to do the rendering for it. However, V8 has become so popular (as seen with Node.js), so I'm curious if there are any new libraries that utilize it or there has since been a browser-independent solution, which I'm not aware.
I might usually consider this a closable question, but with so few results when Googling and on Stack Overflow, there shouldn't be too many solutions (if any).
Related (older) Questions:
How can I use Perl to grab text from a web page that is dynamically generated with JavaScript?
How can I handle Javascript in a Perl web crawler?
You mentioned Selenium but there is the later version Selenium::Remote::Driver which works with a selenium 2.0 hub.
I see you can also use it without a Selenium hub
Without Standalone Server ( I haven't used this part)
As of v0.25, it's possible to use this module without a standalone
server - that is, you would not need the JRE or the JDK to run your
Selenium tests. See Selenium::Chrome, Selenium::PhantomJS, and
Selenium::Firefox for details. If you'd like additional browsers
besides these, give us a holler over in Github.
PhantomJS may be of interest as it is a headless browser
This is probably not an answer but it was too long for a comment

Get Reference to top level ReactJS Component

So I am trying to inject some javascript into a website to scrape some information. However, if I could get a reference to the react component my life would be made a lot easier. I have looked at several questions on Stackoverflow but nothing useful turned up:
Reactjs - Get a component from anywhere in the app
React - get React component from a child DOM element?
I realize that react is basically just rendering the DOM by using its internal state and so reversing the DOM is not an option. Moreover, since the javascript on the website isn't mine I can't exactly have a global reference to the React component when its created. What I would really like is to have the '$r' that the react chrome devtools provides when you choose a DOM element but without having to rely on the chrome extension. I guess my question really boils down to how can I get the same representation that the chrome dev tools does so that I can reference a react component without actually creating a global variable. Also note I don't really care about efficiency or best practices I just want the reference to the component the same way that the devtools does it.

Tracing DOM element id back to its ExtJs component

We are develpoing a web-based automation solution for a web application that is built using ExtJs.
Currently i am testing various different object identification techniques that identify web elements in the best way.
We'd like to use the IE developer tools (F12) to highlight and select DOM objects on the page, and (somehow) get their corresponding ExtJs component (along with its corresponding properties, such as itemId).
Is this possible to do through code or through some other technique?
I am unfamiliar with IE Dev tools for such things, however I can attempt to answer targeting specific components and their elements.
You can target Ext components via several ways:
Ext.ComponentQuery.query(CQselector) method (see docs for examples)
Ext.getCmp(componentID) if you know component ID
up() and down() methods from any container/component. these also take CQselector expressions
Any of these methods are accessible from the page since Ext library is loaded. In browsers like FF and Chrome you can execute these methods directly from the console. I am guessing similarly they should be available in IE Dev tools.
Once you have reference to the Ext component you can get HTML elements through .dom or .el or similar properties. Or you could use Dom query directly.
I believe that if you set the id property rather than the itemId, you can achieve the desired result as this is passed through as the html id property of the top level container for the component (I think!). It's a little complicated to get that to work with accuracy though given the amount of nested divs/tables that are used in most of the extjs components. Good luck!
Hard to tell what you're looking for, but if you're trying to get a reference to an Ext.Component that is rendered, you can look for the wrapper node for your component in the HTML structure. The HTML id is the same as the component id. If you run var comp = Ext.getCmp('some-id-12345') and if that returns something, you've found the wrapper for an Ext.Component.
You could then use
comp.itemId
To retrieve the itemId
You should look into http://www.illuminations-for-developers.com/ A plugin for firebug that shows Ext.Components.
You can also use the Sencha Page Analyzer to see the entire component tree

How to begin using HTML DOM

I have trouble understanding how some things are related.
For a Wordpress plugin, I would like to use HTML DOM on content from wp_remote_open to find a string.
In order to use DOM, does it have to be enabled by my webhost? or do I include a DOM parsing script with the plugin?
I was thinking that if it needs to be enabled by the webhosting company, I would rather use a regular expression to find the string because then it would be compatible for everyone's installation.
DOM has nothing to do with your hosting provider or infrastructure. It is merely a model representing your HTML document. Most modern browsers support DOM. See more at the XML DOM introduction