I play card games on a board game platform called BoardGameArena.
Now I'd like to have a card tracker-helper that would inform me about the remaining cards for one of the games called "Papayoo". The entire log is available while playing the game so should be a pretty straightforward Chrome extension, right?
All of the relevant action happens on the right side of the page:
<div id="right-side-second-part">
<div id='logs_wrap'>
<div id='logs'>
<div id='seemorelogs'><a id='seemorelogs_btn'href='#' onclick='return false'></a></div>
</div>
</div>
</div>
It's a bit weird that I see an empty template like above if I do "View Page Source" of "Save Page As", but the <div id='logs_wrap'>
is being populated during the game, and I can see the entries appear using the "Inspect" functionality. But maybe that's expected for the fields that are being populated dynamically (I'm not a web developer).
Anyway, here is my hello world attempt for a Chrome extension:
manifest.json
{
"name":"Papayoo Helper",
"description":"Papayoo game helper for the BGA platform",
"version":"1",
"manifest_version":2,
"content_scripts": [
{
"matches": ["http://boardgamearena.com/*/papayoo*"],
"js": ["tracker.js"]
}
]
}
an example URL of the game is https://boardgamearena.com/7/papayoo?table=122356466 so I assume it should be matched by my rule.
tracker.js
document.getElementById("right-side-second-part").innerHtml = "<div id='tracker'>Hello world!</div>" + this.innerHtml;
and it should prepend my "Hello world!" to the existing element.
I load the extension by visiting chrome://extensions/
and selecting "Load unpacked".
It doesn't work as nothing is displayed, which leads to the following questions:
- How to debug the behavior and see why it doesn't get loaded?
- How to adjust it to update automatically (or at least frequently)?
I guess the logic will be simply to iterate elements within <div id='logs'>
once the extension itself is working.
Thanks!