elzi
elzi

Reputation: 5672

creating a javascript bookmarklet with variables declared in page

absolute novice at js, as a disclaimer.

there's a page that exists that has variables declared such as:

c="hello"
cd="12345"

and a php viewing script that makes the image only "accessible" (it's hidden under a flash layer otherwise" by a swf that loads:

 ((("view.php?cid=" + c) + "&cd=") + cd)

so the url ends up looking like

 view.php?cid=hello&cd=12345

would it be possible to turn this into a javascript bookmarklet?

thanks

-A

EDIT for clarity for Sno0py:

Neither of the pages are my site. It's a site I'm trying to create a bookmarklet for. On the page, there is flashembed.js, which can be used for a multitude of things, but in this case, in used to make it so you can't right click to save an image (makes it a movie, and with a php view script, puts the image in it).

On the page, there is this html/javascript:

<div id="viewer">
    <!-- image is here -->
</div>
<script type="text/javascript">
    flashembed("viewer",
    {src: "overlay.swf"},
    {c: "hello", cd: "123456"}
    );
</script>

where #viewer is specified in another js script, and c & cd are randomly generated identifiers for the image.

overlay.swf does this:

stage.showmenu = false;
loadmovie ((("http://example.com/view.php?cid=" + c) + "&cd=") + cd, _root);
_root.stop();

so navigating to http://example.com/view.php?cid=hello&cd=123456 would yield the raw data for the image. you can view it with <img src="view.php?cid=hello&cd=123456"> though.

SO: to clarify, would I would like, is a javascript bookmarklet that grabs c and cd, forms the url, and brings you to a page with just the <img src"yadayada"> from above. If that's not possible, just bringing me to the url would be nice.

Upvotes: 0

Views: 1549

Answers (1)

DG.
DG.

Reputation: 3517

If c and cd where variables within the scope of the page, you could simply use this bookmarklet:

javascript:document.location = "http://example.com/view.php?cid=" + c + "&cd=" + cd;

However, they are not. They are attributes of anonymous objects passed as parameters to the function flashembed.

If that function then assigned them to variables in a scope that the bookmarklet could access, then you could use those variables instead, but I seriously doubt that it does.

You are basically left then with the only other option, which is to parse the raw HTML of the page (document.documentElement.outerHTML), most likely with a regular expression.

Upvotes: 1

Related Questions