Explore Safari Web Extension improvements

RSS for tag

Discuss the WWDC21 session Explore Safari Web Extension improvements.

View Session

Posts under wwdc21-10027 tag

24 Posts
Sort by:
Post not yet marked as solved
0 Replies
103 Views
I'm developing a Safari extension and the feature is rating a web page opened by user and will show a block page if the web page contains some phishing link window.location.href = safari.extension.baseURI + "blockpage/blockpage.html?herf=" + window.location.href + "&score=" + score + "&level=1"; It works fine in Safari 15.3 and other version below 15.4. But there is an error on Safari 15.4 It seems path component of "blockpage" is missing. The right path should be "safari-extension://4506B856-D122-4301-93FD-712FDCC4EF14/blockpage/blockpage.html" Any comments will be appreciated. Thanks a lot.
Posted Last updated
.
Post not yet marked as solved
0 Replies
184 Views
Hi, I am working on safari web extension for iOS, Since Message passing is only supported from safari extension to iOS application. To pass the data from app to safari extension, I thought of storing the required data using the Userdefault suite name and "app group" to access the UserDefaults data from the safari extension. I am stuck at how to access the data at the safari extension. Any sample javascript to access the UserDefaults data is appreciated Thanks
Posted Last updated
.
Post not yet marked as solved
1 Replies
220 Views
I keep seeing people with this issue being told to turn off GPU: Process and Capture. However my phone doesn’t have either. All my apps and phone are up to date. I’ve restarted it as well. No idea what else to do?
Posted
by Jb1979.
Last updated
.
Post not yet marked as solved
1 Replies
297 Views
With a Safari extension I add a link to certain websites to open the Maps app with coordinates found on the website. In the content script I detect clicks on my added link and forward the message to the background script with browser.runtime.sendMessage({ coordinates: "some coordinates I found on the website" }). The background script receives this message in its listener function and forwards the message to the extension handler like so browser.runtime.onMessage.addListener((request, sender, sendResponse) => { browser.runtime.sendNativeMessage( { message: request.coordinates }, function(response) { }); } The extension handler receives the message in its func beginRequest(with context: NSExtensionContext) function as expected. In this function I convert the coordinates I receive to a valid CLLocationCoordinate2D object. However, if I want to use the following code inside the beginRequest function to open the Maps app, it does not work on iOS. The same code works fine with a macOS Safari extension. MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 50.1234, longitude: 8.1234))).openInMaps()
Posted
by andre07.
Last updated
.
Post not yet marked as solved
0 Replies
217 Views
Hi, According to Blocking Content with Your Safari Web Extension, we can now use the Declarative Net Request API to block content in a Safari Web Extension. However, not everything in the API has been implemented just yet. The supported RuleCondition are domainType, excludedResourceTypes, isUrlFilterCaseSensitive, regexFilter, and resourceTypes. Does anyone know when the initiatorDomains rule condition will be supported? In the meantime, is there a way for an extension to block requests based on an originator domain? Thanks
Posted
by zogstrip.
Last updated
.
Post not yet marked as solved
2 Replies
409 Views
I was tracking down an infinite loop and it's caused by calling: browser.i18n.getMessage('faq_4a', ['$13.99']) Where the "faq_4a" is defined as: "faq_4a": { "message": "Highlight all prices like $1" }, The problem is the parameter ['$13.99'], if I use this parameter for any message that accepts a placeholder, it will just froze the console or whatever executed it. Can someone please try to run this code to verify? I need to know if this is a Safari issue or if just my Safari broken. I use Safari 15.3 (17612.4.9.1.8). Thank you!
Posted
by Juraj_M.
Last updated
.
Post not yet marked as solved
1 Replies
401 Views
I learned there are two types of safari extensions . Web extensions and app extensions . We are currently developing a safari web extension . The extension requires access on all web sites by default (without user granting permissions) . But there is no provision for same in web extension . However the same can be achieved in app extension by including safari website access  in info.plist . Please clarify why there is no provision to achieve the same in web extension . However same is provided in app extension .
Posted Last updated
.
Post not yet marked as solved
1 Replies
331 Views
Safari version : 15.3 Os version : 12.2.1 This is after latest updates and manifest v3 is not supported. So i need to downgrade manifest version to 2. What can be the solution to run manifest v3 with current mac and safari version? Also, My safari is not getting updated after updating os, Im using intel processor. What can be done to update safari version to 15.4?
Posted Last updated
.
Post not yet marked as solved
1 Replies
257 Views
I am trying to build a utility application on macOS to manage a number of Safari windows and/or tabs. The first task that stumps me is opening a new window. I went back to the basic, created a new "Safari Extension App" project in Xcode 13.2.1. The sample code includes SFSafariApplication.showPreferencesForExtension(withIdentifier:) and that works fine. But when I add my call to : SFSafariApplication.openWindow(with: URL(string: "https://www.apple.com")!) then nothing happens. I tried adjusting the content of NSExtension in the Info.plist of the web extension handler, and a number of other things in the manifest, I verified that my extension was well loaded and active, but without any success with openWindow. Is there any obvious caveat I should be aware of when dealing with SFSafariApplication? Among other questions, should openWindow(...) be in the main app, in the native extension, or either?
Posted
by DryRun.
Last updated
.
Post not yet marked as solved
0 Replies
293 Views
new Worker(browser.runtime.getURL('source/worker.js')) throws an error: Error: This script should only be loaded in a browser extension. I have a hefty background processing operation that I need to pass off to a web worker, but the script I try to execute causes this error. Is there a standard way of spawning a web worker in a background script for a safari web extension?
Posted
by uzinator.
Last updated
.
Post not yet marked as solved
0 Replies
317 Views
I need to perform SSO login using WkWebView and I am not using SFSafariViewController because the URL which I use is a normal web URL and I need to stop loading of next page as soon as I get a ID value in the URL as Query parameter. Now, When I use WKWebView I am unable to logout the previous session saved in WKWebView itself until I manually clear the cache of it. is there any way I can sync Safari and WkWebView sessions, So, if I login in WkWebView I can logout the same from Safari. I have tried using ASWebAuthenticateSession but as I said I need to stop the next page reload. HELP!!!
Posted
by JatinGarg.
Last updated
.
Post not yet marked as solved
8 Replies
2.3k Views
We are trying to develop a Safari extension for the upcoming iOS 15. We are facing unsolvable issues with the memory limit. Our extension handler uses close to zero memory, and 80% of the memory is taken by Apple libraries. So, any time we actually do something in our handler – it crosses the 6MB limit and it gets killed. Is there any way to avoid this, or are there any plans to increase the memory limit in future betas?
Posted Last updated
.
Post not yet marked as solved
0 Replies
457 Views
except blocking images on any website opened except wikipedia, like https://www.mozilla.org, all images show up on every website [ { "id": 1, "priority": 1, "action": { "type": "block" }, "condition": {"regexFilter": ".*", "resourceTypes": [ "image" ] } }, { "id": 2, "priority": 1, "action": { "type": "allow" }, "condition": {"regexFilter": "wikipedia", "resourceTypes": [ "image" ] } } ] I downloaded the sample app from https://developer.apple.com/documentation/safariservices/safari_web_extensions/adopting_declarative_content_blocking_in_safari_web_extensions signed all targets, cleaned build and run on mac. Enabled the extension in safari preferences and clicking the icon in the status bar displays this "Blocks images on most webpages." message, so the extension seems to be running in safari. the sea creator sample works fine and i wonder why this web content blocker just won't adding activeTab to manifest.json didn't make a change { ... "declarative_net_request": { "rule_resources": [ { "id": "ruleset_1", "enabled": true, "path": "ruleset_1.json" } ] }, "permissions": [ "declarativeNetRequest", "activeTab" ] }
Posted
by ioect.
Last updated
.
Post not yet marked as solved
0 Replies
384 Views
This documentation guide and the corresponding demo project show how the the Web Extension Handler can inherit from NSExtensionRequesetHandling and implement beginRequest to receive and reply to messages sent from the background script via browser.runtime.sendMessage(). The guide also mentions how browser.runtime.connectNative and SFSafariApplication.dispatchMessage can be used to send messages from the Handler to the background script, but the code is not in the example project. Further, it seems that SFSafariApplication is not available on iOS. How can I send a message originating from the Extension Handler to notify the background script of events coming from native code (e.g. UserDefaults changes)? Is polling from the background script the only option?
Posted
by s-ol.
Last updated
.
Post not yet marked as solved
0 Replies
391 Views
Issue while trying to make a startsession call for web touchpoint. Curl command works for same PEM file which is used which same gives error using JAVA. java.io.IOException: toDerInputStream rejects tag type -126 at sun.security.util.DerValue.toDerInputStream(DerValue.java:873) ~[?:?] at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1997) ~[?:?] at sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:222) ~[?:?] at java.security.KeyStore.load(KeyStore.java:1479) ~[?:?] at *************.createCustomSSLContext(***********.java:92) ~[classes/:?]
Posted
by sneeraj92.
Last updated
.
Post not yet marked as solved
0 Replies
291 Views
is there going to be es6 javascript support in WKWebView (especially modules?)
Posted
by vozzman.
Last updated
.
Post not yet marked as solved
1 Replies
525 Views
Hi, I'm trying to implement a "content blocker" using the DeclarativeNetRequest permission in a Safari Web Extension. I tried to customize the sample app (ios+MacOS) provided by Apple (https://developer.apple.com/documentation/safariservices/safari_web_extensions/adopting_declarative_content_blocking_in_safari_web_extensions). However, I observe : a random behaviour on iOS15: rules do not always apply, or are not reloaded crashes on Monterey Beta9 and Safari 15.1 : com.apple.Safari.ContentBlockerLoader crashes on WebKit:runInitializeCode after ConteRuleListStore... Crash Report Any idea? Is this a "very beta" feature... documentation is so poor compared to Google's. Thanks
Posted
by esellier.
Last updated
.
Post not yet marked as solved
2 Replies
930 Views
We have Safari App(!) Extension, the one that has no background page. We want to port it to a Safari Web Extension, so it can run on iOS 15. The App Extension extensively uses safari.extension.dispatchMessage, and we want to replace it with browser.runtime.sendNativeMessage, which doesn't work at all. There's a couple questions: How to get a response from browser.runtime.sendNativeMessage Do we have to use browser.runtime.connectNative? How to use it? Where is the documentation on all of this?
Posted Last updated
.