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

Direct links don't work (reliably?) if target page embeds the client #1355

Open
robertknight opened this issue Aug 29, 2023 · 5 comments
Open
Labels

Comments

@robertknight
Copy link
Member

robertknight commented Aug 29, 2023

We changed the way that the bouncer service (hyp.is) activates the extension and configures the extension's client to navigate to a particular annotation. This has ended up breaking direct links to annotations on target pages that embed the client.

Example bouncer link: https://hyp.is/zxCckEH4Ee6tPkNgrU9gKw/chem.libretexts.org/Courses/University_of_Arkansas_Little_Rock/Chem_1403%3A_General_Chemistry_2/Text/10%3A_Review/10.01%3A_Lewis_Dot_Structures

If you follow this link in a Chrome browser that has our extension installed, what happens is:

  1. The bouncer (hyp.is) service sends a message to our extension instructing it to navigate to the target page and scroll to an annotation
  2. The extension's service worker receives the message (see src/background/index.ts) and initiates the navigation
  3. When the navigation completes, the extension injects configuration in the page with the details of the annotation to scroll to and attempts to activate the extension in the tab

When the target page does not embed the client, this all works fine. The problem comes when the target page embeds the client. In this case step (3) will inject configuration into the page, but the extension's client does not activate because the embedded client is already there. The embedded client meanwhile will probably not read this configuration because it was not present in the page when the embedded client initially loaded.

Some possible solutions:

  • If the extension detects an embedded client in the page, have it send a message to the embedded client about the direct linked annotation (eg. via a DOM event)
  • Other ideas here...

Slack thread: https://hypothes-is.slack.com/archives/C2C2U40LW/p1693313716998819?thread_ts=1692964809.673489&cid=C2C2U40LW

@robertknight robertknight changed the title Direct links don't work if target page embeds the client Direct links don't work (reliably?) if target page embeds the client Aug 29, 2023
@janraev
Copy link

janraev commented Aug 29, 2023

@dwhly dwhly added the bug label Sep 29, 2023
@dwhly
Copy link
Member

dwhly commented Oct 4, 2023

Could possibly add libretexts.org to bouncer's whitelist of sites that embed the client.

@janraev
Copy link

janraev commented May 28, 2024

@dltj
Copy link

dltj commented May 31, 2024

I'm probably that report immediately above:

I'm using an adaptation of Dan Whaley's DropDoc web application to generate transcripts of YouTube videos and provide a way to annotate bits of the transcript. For example, this post on Mastodon about a recent CNI briefing on JSTOR's LLM-driven bot on journal articles: https://code4lib.social/@dltj/112515330860312283. The links on that Mastodon post work fine. However, if I link to a specific Hypothes.is annotation (as I did in this Mastodon post: https://code4lib.social/@dltj/112515476692600406), the JavaScript bits that enable the reader to jump to a specific time in the YouTube recording stop working. (In other words, if you click on a transcript line in the "media.dltj.org" version of the transcript, the video player jumps to the right time. Through "via" though, it does not.) It seems like the YouTube player is not getting initialized; I see this in the console:

Uncaught TypeError: player is undefined at index.html:1847:9

Digging further, the player is defined by onYouTubeIframeAPIReady() in my JavaScript, but that function isn't being called. When I look at the page without going through Via, I see that the function is being called by a bit of YouTube's JavaScript:

Looking at the browser console, I see that the HTTP request is getting redirected by Via to:

So I'm guessing that Hypothesis has blocked that bit of JavaScript. Are there any known workarounds? [Now adding: I see that there are no known workarounds. Also...the code, in all its mid-refactoring ugliness, is on GitHub.]

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

No branches or pull requests

5 participants