Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

I use technology in order to hate it more properly. -- Nam June Paik


devel / comp.lang.javascript / Re: Bookmarklet code works console, but not from bookmark. Is it caused by iframes?

SubjectAuthor
* Bookmarklet code works console, but not from bookmark. Is it caused by iframes?Alfred
`- Re: Bookmarklet code works console, but not from bookmark. Is it caused by iframJJ

1
Bookmarklet code works console, but not from bookmark. Is it caused by iframes?

<LwGdnefIEeUPlj_5nZ2dnZfqn_WdnZ2d@brightview.co.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=18174&group=comp.lang.javascript#18174

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.22.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 02 Jul 2023 23:43:14 +0000
From: invalid@invalid.invalid (Alfred)
Subject: Bookmarklet code works console, but not from bookmark. Is it caused by iframes?
Newsgroups: comp.lang.javascript
Message-ID: <LwGdnefIEeUPlj_5nZ2dnZfqn_WdnZ2d@brightview.co.uk>
Date: Sun, 02 Jul 2023 23:43:14 +0000
Lines: 19
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-pYjECOrlFl8jOQwFujFHOb+WTLSCsYF/IyadneUXc2Tc2tKkL/DwgERFIeadqZzPihzvj31Fl0iozfv!Idy6XAyXBt8ntfadYY9Bp/jpMVZ2MTUtyzJJXTXvKxYDz1VrmxJ4FROMkSSnOblv+gWXerdIYz0h!F1ii1W4DLmBGUTd3Mdj0VdCxSMa/
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Alfred - Sun, 2 Jul 2023 23:43 UTC

I am filling a form automatically with a bookmarklet, with lines of code like

document.getElementById('id_but1').value = "&nbsp;a"

The code works in the browser console, but not as a bookmarklet.

From reading this SO answer I suspect the problem is caused by iframes.

https://stackoverflow.com/questions/51723626/bookmarklets-doesnt-work-when-run-from-bookmark-but-works-from-console

SO suggests a piece of code like

let Iframe = document.getElementById('iframe_id').contentWindow.document
let value = Iframe.getElementById("textboxID").value = "Some Text"

The problem in my case is that I don't know the id for the iframe,
i.e., I don't know 'iframe_id'.

Any suggestion for knowing the ids of the iframes?

Re: Bookmarklet code works console, but not from bookmark. Is it caused by iframes?

<821628jqwlvl$.1207kpo4g5djq.dlg@40tude.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=18175&group=comp.lang.javascript#18175

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jj4public@outlook.com (JJ)
Newsgroups: comp.lang.javascript
Subject: Re: Bookmarklet code works console, but not from bookmark. Is it caused by iframes?
Date: Mon, 3 Jul 2023 17:48:07 +0700
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <821628jqwlvl$.1207kpo4g5djq.dlg@40tude.net>
References: <LwGdnefIEeUPlj_5nZ2dnZfqn_WdnZ2d@brightview.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="146b8273d531ead2d06b5b5db719f8f6";
logging-data="3876337"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18obLEhweiK+K0bBsq8e2y8JrOtPF0Obv8="
User-Agent: 40tude_Dialog/2.0.15.84
Cancel-Lock: sha1:E+3rTO5YZeLcKbFGfV6uAfzZEic=
X-Face: \*\`0(1j~VfYC>ebz[&O.]=,Nm\oRM{of,liRO#7Eqi4|!]!(Gs=Akgh{J)605>C9Air?pa d{sSZ09u+A7f<^paR"/NH_#<mE1S"hde\c6PZLUB[t/s5-+Iu5DSc?P0+4%,Hl
X-Bitcoin: 1LcqwCQBQmhcWfWsVEAeyLchkAY8ZfuMnS
 by: JJ - Mon, 3 Jul 2023 10:48 UTC

On Sun, 02 Jul 2023 23:43:14 +0000, Alfred wrote:
> I am filling a form automatically with a bookmarklet, with lines of code like
>
> document.getElementById('id_but1').value = "&nbsp;a"
>
> The code works in the browser console, but not as a bookmarklet.
>
> From reading this SO answer I suspect the problem is caused by iframes.
>
> https://stackoverflow.com/questions/51723626/bookmarklets-doesnt-work-when-run-from-bookmark-but-works-from-console
>
> SO suggests a piece of code like
>
> let Iframe = document.getElementById('iframe_id').contentWindow.document
> let value = Iframe.getElementById("textboxID").value = "Some Text"
>
> The problem in my case is that I don't know the id for the iframe,
> i.e., I don't know 'iframe_id'.
>
> Any suggestion for knowing the ids of the iframes?

If the IFRAME content is served in a different origin than the IFRAME host,
it's not possible since bookmarklets are run in the main page context (the
IFRAME host) due to XSS.

A workaround is to use UserScript to run code in the IFRAME content's
context, where the bookmarklet code sends a message event into the IFRAME
content to notify the UserScript message event listener to run a code.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor