Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pentadactyl + JavaScript: getting value of an object? #196

Closed
for-coursera opened this issue Nov 16, 2016 · 1 comment
Closed

Pentadactyl + JavaScript: getting value of an object? #196

for-coursera opened this issue Nov 16, 2016 · 1 comment

Comments

@for-coursera
Copy link

for-coursera commented Nov 16, 2016

Version:

Pentadactyl hg7290 (created 2016/07/19 07:00:08) running on:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Firefox/45.0

Firefox.app in question is actually Firefox Extended Support Release, which still seems to be the latest Firefox available.

Issue:

Let's say I open a random issue page on a GitHub tracker (like this one), then I open Console in Firefox and run something like this:

alert(document.getElementsByClassName("js-issue-title")["0"]["firstChild"].textContent)

As a result, it pops me up with the title of an issue (speaking of this particular issue, it would be How to achieve Ctrl-t functionality).

Now, I want to use that value in a script with Pentadactyl. Thus, I add something like this to my .pentadactylrc

:javascript <<EOF
function dummyFu() {
    var myElement = document.getElementsByClassName("js-issue-title");
    alert(myElement["0"].firstChild.textContent);
}
EOF
map -silent <F5> -js dummyFu()

However, when run, it just says TypeError: myElement[0] is undefined.

I'm do not know much of JavaScript, unfortunately, so there's probably some mistake in my thinking? I just want to be able to get an element from a page by a class and then use it my script... Would be grateful for any suggestion, thanks.

@dkearns
Copy link
Contributor

dkearns commented Nov 16, 2016

See https://developer.mozilla.org/en-US/docs/Web/API/Window/content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants