Safari Extensions

RSS for tag

Enhance and customize the web browsing experience on Mac, iPhone, and iPad with Safari Extensions

Safari Extensions Documentation

Posts under Safari Extensions tag

105 Posts
Sort by:
Post marked as solved
2 Replies
1.5k Views
When using password autofill on Safari 16.4 (Ventura 13.3 on M1 Mac), and a third party password manager, when the proposed credential is selected an exception dialog appears. This is new behaviour since the 16.4/13.3 update. Touch id may be on or off - same result. Traceback from exception: Exception Name: NSInvalidArgumentException Description: -[WBSCredentialIdentityMatch autoFillPasskey]: unrecognized selector sent to instance 0x600003bd3f00 User Info: (null) 0 CoreFoundation 0x000000018928719c __exceptionPreprocess + 176 1 libobjc.A.dylib 0x0000000188da64d4 objc_exception_throw + 60 2 CoreFoundation 0x000000018932e178 -[NSObject(NSObject) __retain_OA] + 0 3 CoreFoundation 0x00000001891ef150 ___forwarding___ + 1600 4 CoreFoundation 0x00000001891eea50 _CF_forwarding_prep_0 + 96 5 Safari 0x00000001b3ffc7b4 -[FormAutoFillCompletionControllerObjCAdapter shouldShowAuthenticationSheetForCompletionListItem:] + 136 6 Safari 0x00000001b3ffa770 -[FormAutoFillCompletionControllerObjCAdapter performActionForListItem:result:shouldAbortCompletion:] + 44 7 Safari 0x00000001b3ff04e8 _ZN6Safari32FormAutoFillCompletionController29performSelectedListItemActionERNS_33FormAutoFillCompletionShouldAbortE + 84 8 Safari 0x00000001b3ffb844 -[FormAutoFillCompletionControllerObjCAdapter menuTableView:mouseUpInRow:] + 56 9 Safari 0x00000001b3f0dbe0 -[MenuTableView mouseDown:] + 312 10 AppKit 0x000000018c5ce474 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3476 11 AppKit 0x000000018c5590dc -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364 12 AppKit 0x000000018c558d9c -[NSWindow(NSEventRouting) sendEvent:] + 284 13 AppKit 0x000000018c5580e0 -[NSApplication(NSEvent) sendEvent:] + 1556 14 Safari 0x00000001b3dc6f64 -[BrowserApplication sendEvent:] + 496 15 AppKit 0x000000018c7a80f0 -[NSApplication _handleEvent:] + 60 16 AppKit 0x000000018c41f57c -[NSApplication run] + 500 17 AppKit 0x000000018c3f69a8 NSApplicationMain + 880 18 Safari 0x00000001b412daa8 SafariMain + 408 19 dyld 0x0000000188dd7f28 start + 2236
Posted
by
Post not yet marked as solved
4 Replies
816 Views
I'm porting a Chrome extension to Safari. The Chrome extension's manifest version is 3 and must stay 3. I've encountered an error around webRequest API where Safari allows this API only on persistent background pages which available only on manifest v2. So, my questions are: Is it possible to use webRequest API on manifest v3 Safari extension? If no, is there any alternative API to listen to requests? Is it something that going to be supported soon? It feels really strange that his basic API is not supported by Safari while the rest of browsers supports this.
Posted
by
Post not yet marked as solved
2 Replies
533 Views
Safari extension MV3, MacBook Pro with Ventura 13.3.1, Safari 16.4 and Xcode 14.3 Although the “webkit features in Safari 16.4” claims to support requestDomains condition, any attempt to load a ruleset containing that condition fails. The extension’s manifest declares the permissions and the ruleset to use: "permissions": [ "declarativeNetRequestWithHostAccess", "declarativeNetRequestFeedback" ], "declarative_net_request": { "rule_resources": [ { "id": "ADS", "enabled": false, "path": "rules/adstest.json" } ] } This is the ruleset used for tests: [ { "id": 1, "priority": 1, "action": { "type": "block" }, "condition": { "requestDomains": ["testpages.kzar.co.uk"] } } ] The ruleset is enabled by the service worker with this function: function EnableDNRRules() { return new Promise( (resolve, reject) => { browser.declarativeNetRequest.updateEnabledRulesets( { enableRulesetIds: [ 'ADS' ] }, () => { console.log("LAST ERROR",browser.runtime.lastError) resolve(true); console.log("dNR rules enabled"); }); }); } The result in last error is: “Failed to apply rules” and rule is not used at all. If I enable the ruleset directly in manifest, and not using the function to load the ruleset, the rule is simply not applied (so not loaded at all). In Chrome and Firefox the same code/ruleset works fine, but not in Safari 16.4, although the docs say it works. Using different condition (e.g. urlFilter) works fine in Safari too. The expected behavior is to have requestDomains working too, as per 16.4 documentation.
Posted
by
Post not yet marked as solved
0 Replies
428 Views
Hi Team, We have Flight Check-in functionality on our app that helps the end users to perform Mobile Check-in and to select the seats on the flight. This Checkin page is a Refx page created by Amadeus and we are loading the weblink on the WKWebview to show to the users. In order to select the seat on the seatmap, the webview has to show the seatmap on the app. But, unfortunately the app's webview is failing to load the seatmap component that is created by Amadeus(third party) on the webview. But the seatmap is loading perfectly on iPhone's Safari browser, Macbook Safari browser and Android app as well. We tried to load the Check-in flow via SFSafariViewController and the seatmap renders correctly. We want to know why the page is not loading on the WKWebview. We need your technical help related to this issue. STEPS TO REPRODUCE This is an upcoming feature on the app and is not available on the LIVE app. We are facing this issue on the developer version. We would request your connect to debug/trace the issue
Posted
by
Post not yet marked as solved
1 Replies
322 Views
I have found two Safari Extension issues that reproduce on iPad 6th generation and not on iPad 8th generation. Have any of these events been reported? 1. content_scripts is not executed immediately after Safari is launched After closing Safari, the content_scripts that the Safari Extension is supposed to execute in the Safari tab immediately after startup are not working. In our app, we are using background's webNavigation.onDOMContentLoaded to run as content_scripts. We are reproducing this issue about 50% of the time. 2. 2. sendNativeMessage response is not returned The following code sends a message from the Safari Extension to the application, but sometimes neither response nor error is output. browser.runtime.sendNativeMessage('application.id, {}) .then((response) => { console.log(response) }) .catch((error) => { console.error(error) }) This problem reproduces about 5~10% of the time.
Posted
by
Post not yet marked as solved
0 Replies
457 Views
Hi We have a working chrome extension(using manifest version 3) with content security policy having frame-src: <remote_urls> "content_security_policy": { "extension_pages": "script-src 'self'; child-src 'self'; style-src 'self' 'unsafe-inline'; frame-src https://abc.com https://xyz.com" } We converted the extension using a utility (safari-web-extension-converter) to make it work in Safari and faced the following error while testing- Refused to load: https://abc.com/h.html because it does not appear in the frame-src directive of the Content Security Policy. Environment Details macOS - 13.4 Safari - Version 16.5 (18615.2.9.11.4) Xcode - Version 14.3 (14E222b) Can you help us with the correct way to define the frame src directive of the content security policy in the extension?
Posted
by
Post not yet marked as solved
2 Replies
675 Views
Hi. For my Safari Web Extension, using getMatchedRules() from declarativeNetRequest does not seem to work. I've declared the permission for declarativeNetRequestFeedback in my manifest.json file and tried the activeTab permission too. getMatchedRules() was added in a previous Safari release and was adjusted in Safari 16.4. I'm using Safari 16.5. It only returns an empty array when it's called. I know the rules are there and they're being applied from the static rules json, it's just that getMatchedRules() is not showing them for some reason. I'm using: const rules = await browser.declarativeNetRequest.getMatchedRules(); But it only ever returns: {rulesMatchedInfo: []} Can anyone tell me what I'm doing wrong please? The same code works fine in Chromium based browsers. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
355 Views
Some users send me error logs which says that the IndexedDB is broken (all DB operations throws TypeError: Load failed). And reinstalling doesn't help. It seems that uninstalling extension doesn't delete all data so the corrupted database is still there. How can I find and delete the extension files manually after it's been uninstalled?
Posted
by
Post not yet marked as solved
0 Replies
415 Views
Hi guys....we're having issues having instagram embeds showing up on our site in Safari. We use iFramely's oEmbed. They show up fine in Chrome. Firefox also blocks it and I sense it might be handling these like some kind of third party cross site tracking and blocking them from showing up. Is anyone aware of this? Any workarounds?
Posted
by
Post not yet marked as solved
3 Replies
737 Views
There is a bug where the service worker will crash when trying to start loading up again. I was able to narrow it down somewhat, and have reported feedback to Apple. Anyone else notice anything similar? I hope it gets fixed soon. https://github.com/getchardy/safari-extension-bug-service-worker-crash
Posted
by
Post not yet marked as solved
1 Replies
993 Views
Hi, In the WWDC23 session “What’s new in Safari extensions,” the presenter says: There are four ways to build Safari extensions: content blockers, share extensions, app extensions, and web extensions. Safari 17 continues to support all of these types, but the future of browser customization lies in web extensions. I take that to mean that content blocker extensions won’t be supported indefinitely, so I would like to get ahead of this by migrating my CSS content blocker to a web extension. However, I don’t see an API which allows for declarative CSS blocking in the same privacy-preserving way. I like the current way of building CSS content blockers because I can block page content without requesting any additional permissions. This provides a very smooth user experience, but I don’t see any way to do this using Safari web extensions. This method of blocking content is even referenced in the video, but only as a way to draw parallels to Declarative Net Request. Did I miss a change that allows me to build a privacy-preserving CSS content blocker in a web extension?
Posted
by
Post not yet marked as solved
0 Replies
381 Views
Hi all, I've encountered this bug where runtime.onInstalled won't work unless permissions are enabled. Yet, I've noticed that this feature works when installing an app from Honey. Video attached: This works as soon as you enable permissions, and flawlessly on macOS, but iOS requires these permissions for it to run. Any thoughts? Can't figure out what the problem is: https://www.dropbox.com/s/a48ixh58wjpc2tj/onInstalledEvent.MP4?dl=0
Posted
by
Post not yet marked as solved
1 Replies
574 Views
I can check if my Safari app extension is enabled using the SFSafariExtensionManager getStateOfSafariExtensionWithIdentifier API. I can also check if the URL was opened in private mode using the SFSafariPageProperties usesPrivateBrowsing API. But this doesn't solve my problem. I want to know if my Safari app extension is enabled in private mode and I also want to know if the extension allows tracking all websites. I am trying this with Safari 17 on macOS 14 Beta.
Post not yet marked as solved
1 Replies
401 Views
I am wondering if Safari Web extension have Single Purpose Policy like Chrome. Here are some description on Single Purpose Policy, reference from https://developer.chrome.com/docs/extensions/mv3/single_purpose/#three . Please let me know if Safari extension has policy like this, thanks!
Posted
by
Post not yet marked as solved
1 Replies
735 Views
Declarative net Request modify header rule is not working for safari. Works fine on all other browsers (chrome, edge , FF etc) Error: [Error] Error: Invalid call to declarativeNetRequest.updateDynamicRules(). Error with rule at index 0: Rule with id 100 is invalid. The header x-source is not recognized. > > let x = [{ "id": 100, "priority": 1, "action": { "type": "modifyHeaders", "requestHeaders": [ { "header": "x-source", "operation": "set", "value": "test" } ] }, "condition": { "urlFilter": "https://*/*" } }] await browser.declarativeNetRequest.updateDynamicRules({ addRules: x }); However, if I change the header name to "Origin" it works. Is there a restriction on which all header names are supported?
Post not yet marked as solved
2 Replies
438 Views
We have a native safari extension for macOS with an NSTokenField and completions. When clicking one of the completions in the list, the window for the extension closes as though you had clicked outside of it, even if you click in the portion that intersects the popup. If I run the extension as a regular app, the issue doesn't happen. The click registers and adds the token from the completion list. I filed feedback (FB12606023), but need to fix the issue also. Is this somehow expected in a popup?
Posted
by
Post not yet marked as solved
2 Replies
619 Views
Sometimes Safari is rendering the icon for an active extension in its original provided colored representation, other times Safari is applying an overlay color in line with the system's highlight color. This difference can even be seen seen on the Safari Extensions Developer home page: https://developer.apple.com/safari/extensions/images/extensions-hero-large_2x.png You will notice that Grammarly's icon is shown in it's original color format, while the others aren't. Example of extensions where the icon is shown in color: Bitwarden Grammarly 1Password Consent-O-Matic I've compared the source code of Bitwarden and Consent-o-Matic with my own extension and cannot find any differences in the settings or image properties (resolution, DPI, file type, color profile). If I take the exact PNG source files from said open source extensions and replace them in my own source code, these icons show up in full color. Does this perhaps mean there is a bug in Safari's processing of the icons where it fails to overlay the icon with the highlight color in some cases? I and I assume many developers with me would like to understand what determines this difference. Ideally, there is a consistent UX where the end user has the choice between icons in color or highlight color overlay.
Posted
by