I'm working on a opera extension that will search for a specific element on the current page once clicked. But I'm lost and I don't know what to do since I'm a very beginner in html/js stuffs.
The value that I am trying to extract from the page source is:
<script type="text/javascript">
var DEFAULT_URL = '/test/files/db9594e7e810cccdceb2e4faae6339a8.pdf';
</script>
What should I do to extract this kind of attribute value from a pdf viewer link's page source? Any help would be appreciated, thank you in advance.
There must be a way to just access window variables from an opera extension... Can't you just access window.DEFAULT_URL since that variable has been set?
As an alternative, you should be able to parse it out manually. The code below will give you all the script tags:
document.querySelectorAll("script")
If you want to get the content of the first script tag, you should be able to do so with:
document.querySelectorAll("script")[0].innerHTML
Once you've got that, you should be able to parse and extract the URL that you need from it.