Plasma Browser Integration 1.9

I’m pleased to announce the immediate availability of Plasma Browser Integration version 1.9 on the Chrome Web Store. This is a maintenance release shipping a couple of important changes as well as the usual translation updates. The extension now ships 46 different localizations and will of course continue working just fine under the upcoming Plasma 6!

Dark blue space background with stars, a cute dragon wearing a red bandana with a "K" on it, sitting ontop of the Earth which has a blue network cable plugged in whose lose end is squiggling around the KDE Plasma logo
Konqi surfing the world wide web

Plasma Browser Integration bridges the gap between your browser and the Plasma desktop. It lets you share links, find browser tabs and visited websites in KRunner, monitor download progress in the notification center, and control music and video playback anytime from within Plasma, or even from your phone using KDE Connect!

The Firefox update has been stuck in review for a month now, so I decided to just release this announcement anyway. When Firefox users will get the update? I don’t know. The update on the Microsoft Edge store has been postponed for now as they demand Manifest Version 3. A migration in the works and will be released in time before Chrome starts disabling “legacy” extensions.

What’s new?

(also see the Changelog Page on our Community Wiki)

Reworked page injection code

While most Plasma Browser Integration features can be provided independently from any websites by using official browser extension APIs, adding media controls and the Web Share API requires adding some variables to the website’s JavaScript environment. Previously, this was done by injecting JavaScript tags into the DOM which then had access to the website’s realm. However, with the advent of Content Security Policy this became more and more restricted. While this is a good thing, it proved challenging for Plasma Browser Integration to continue offering the functionality people have grown to love over the years.

Firefox in particular for the longest time has been enforcing CSP even for browser extensions with access to a particular website. However, Manifest Version 3 in Chrome also does the same, so there will soon be no way around it. Thanks to Fabian Vogt, the extension has been ported to use a static script file with all endpoints pre-defined as opposed to injecting JavaScript strings built at runtime. It then communicates back and forth with the website using custom events. This makes the extension much more resilient and future-proof but more importantly makes media controls in Firefox fully work on Spotify!

Firefox window showing the website, context menu emerging from its tab on the tab bar, last option on the menu is “Share…” highlighted by the mouse cursor
Generic “Share…” option on the tab bar

Speaking of Firefox, Joshua Jackson ported browser detection away from checking for the InstallTrigger, which is deprecated. Additionally, the generic “Share…” entry is now available on a tab’s context menu alongside KDE Connect just like on the website’s context menu.

Performance improvements

Additionally, to improve startup performance, download monitoring is now only installed once a download has been started. On startup, the browser might send us an event about every single download (often hundreds!) that is still stored in the downloads history, even though we don’t care about them. Furthermore, thanks to Ambareesh Balaji the media players are now tracked in a WeakSet to reduce the likelihood of a memory leak of keeping long gone player instances alive.

From Plasma 5.27 Media Session API album cover processing is more lenient toward malformed data: SoundCloud has a bogus letter “t” in the image size string which previously broke displaying the album cover in Plasma’s Media Player applet. I reported that issue to their support in December 2022 but the issue still hasn’t been resolved. There have also been fixes to improve players in iframes, such as an embedded Vimeo player.

Everything else

In addition to that, Plasma Browser Integration no longer sometimes pretends to be a random web app rather than the browser it launched from. The tabs runner also excludes windows from web apps now as they are in a separate window and might as well be accessed via the “Open Windows” runner.

The history runner also filters “blob” URLs. Those are URLs pointing to data dynamically generated by JavaScript and cannot be referenced after the page that created the URL has closed.

Snippet from the extension console output, showing various debug messages and warnings.
Should something go wrong on the host side, you’ll see that more easily.

Calls to Native Messaging meanwhile check whether the port actually is open before sending a message. This avoids repeated console warnings being generated when the extension is installed on an unsupported system, as can easily happen when it is synced across devices to e.g. a Windows machine. Finally, debug output coming from the host binary looks much prettier in the developer console now.

7 thoughts on “Plasma Browser Integration 1.9”

  1. Thanks to you and to any other contributors to this, it’s one of those things that makes KDE/Plasma such a pleasure to use!

  2. I feel like at least some of this functionality ought to be native browser features. Media control, for example, probably uses MPRIS D-Bus protocol and therefore desktop-agnostic (though specific to Linux / “freedesktop platforms”).

    1. Both Firefox and Chromium implement MPRIS nowadays but both with questionable quality. Also, Plasma Browser Integration predates native browser MPRIS support by many years.

    1. You could clone the git repo and temporarily load the extension’s manifest.json from about:debugging#/runtime/this-firefox

      Unfortunately this doesn’t install an extension in the browser, it only loads it temporarily in the current session.

    2. Complain to Mozilla, it’s been months of radio silence. I really try to like Firefox (so there is at least some alternative to Chromium) but they’re surely not making it easy.

Leave a Reply

Your email address will not be published. Required fields are marked *