Post not yet marked as solved
Hi, I have an extension on which I have allowed "foo.com", but then from permissions in manifest.json I removed "foo.com" then re-built the extension but still see "foo.com" in the extension's permissions list in preferences.
Then I uninstalled the extension and re-built, still I can see "foo.com" in the list and allowed, it should not have been there, as I have removed now.
How do I reset an extension in Safari? If even uninstalling and reinstalling is not working?
Thanks
Post not yet marked as solved
Hi in my web extension I have a button, which I programmatically create a file for download when the user clicks it.
Here is my code: a.click()
However, this does nothing when I do it within the popup. It works fine on the main Safari webpage. Am I doing something wrong?
Safari browser(especially 15.4).
I have few html pages deployed as part of extension.
When I try to set the current Tab page url to one of these html pages, extension stops working.
May I know why ? Am I doing something wrong here ?
I have updated my web extension to use Manifest v3.
While trying to test, I get the error:
_The service_worker script failed to load due to an error.
_
I do not see details on the error, or a place where to find details. Any suggestions?
I am creating a Safari App Extension for users to save web links and quotes to my app. I would like to cache web page metadata when links are saved by the extension.
I am using a context menu command to capture information with the code below.
override func contextMenuItemSelected(
withCommand command: String,
in page: SFSafariPage,
userInfo: [String : Any]? = nil)
{
switch command {
case "sendToApp":
Task {
guard let properties = await page.properties(),
let pageURL = properties.url else {
return
}
let provider = LPMetadataProvider()
provider.timeout = 0.01
os_log("*** Starting metadata call ***")
let metadata = try? await provider.startFetchingMetadata(for: pageURL)
os_log("*** Continued past metadata call ***")
// ...
}
}
I get the log:
*** Starting metadata call ***
LPMetadataProvider<1>: start fetching for URL
...but I am never seeing the log "*** Continued past metadata call ***"
I wonder if the task is being killed for some reason?
I thought maybe async code was an issue in SFSafariExtensionHandler, but the first await call in the guard passes successfully.
I thought that the default timeout of 30s on LPMetadataProvider may be too great, but it still fails with a tiny timeout of 0.01s.
I have added com.apple.security.network.client to the entitlements of the extension.
Is there something I am missing please?
Post not yet marked as solved
Hello, I want to test build & sign manually a safari extension for self distribution.
The safari extension contains no content, just a hello world pop-up.
For this kind of extension do I need to have custom Entitlements or a Provisioning profile? I can't find anywhere on the internet if a blank/empty safari extension needs some Entitlements for manually code signing.
To sign a safari browser extension manually I just have to take the compiled .app and manually code-sign it? With no entitlements and no provisioning profile and no other stuff?
Does anyone have some experience with manually signing Safari browser extensions and can help with this?
Thanks!
Post not yet marked as solved
I recently converted my Chrome extension to a Safari extension using the Apple Conversion tool (XCode CLI). The extension is developed with ReactJS and SaSS.
It works very well on Google Chrome but when I try it on Safari after converting it, the local extension works but the CSS file that handles the extension is not applied.
There are no errors during the conversion but the Safari developer tool indicates several errors :
console tab : Failed to load resource: You are not allowed to access the required resource.
network tab : An error occurred while trying to load the resource and the resource was requested in an insecure manner.
In the extension, we isolate CSS using iframe :
/*global chrome*/
/* src/content.js */
import React from 'react';
import ReactDOM from 'react-dom';
import Frame, { FrameContextConsumer }from 'react-frame-component';
import "./content.css";
class Main extends React.Component {
render() {
return (
<Frame head={[<link type="text/css" rel="stylesheet" href={chrome.runtime.getURL("/static/css/content.css")} ></link>]}>
<FrameContextConsumer>
{
// Callback is invoked with iframe's window and document instances
({document, window}) => {
// Render Children
return (
<div className={'my-extension'}>
<h1>Hello world - My first Extension</h1>
</div>
)
}
}
</FrameContextConsumer>
</Frame>
)
}
}
Here is the manifest.json file:
{
"short_name": "My Extension",
"name": "My Extension",
"version": "1.0",
"manifest_version": 3,
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"action": {
"default_icon": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"default_title": ""
},
"background": {
"service_worker": "background.js"
},
"content_scripts" : [
{
"matches": ["<all_urls>"],
"css": ["/css/root.css"],
"js": ["/static/js/content.js"]
}
],
"permissions": [
"activeTab",
"scripting",
"storage"
],
"host_permissions": ["https://www.google.com/*"],
"web_accessible_resources": [{
"resources": [
"/static/css/content.css",
"/static/media/*"
],
"matches": ["<all_urls>"]
}]
}
After many attempts, I did not understand the exact origin of the problem and I do not know how to solve it. Do you have any suggestions ?
Post not yet marked as solved
I have a content blocker in my app and in app I check to see if the content blocker is enabled. Since iOS 15.4 the is enabled does not change unless the app is killed and reopened.
When the app is put into the background and the user goes to iOS Settings>>Safari>>Extensions and enables the Content Blocker then returns to the app, the content blocker state still returns isEnabled as false until the app is fully terminated and reopened. The same is issue occurs when disabling the content blocker (although in this scenario it returns isEnabled as true until the app is killed and reopened.)
This worked fine on all versions of iOS up until 15.4
This is the code I am using:
SFContentBlockerManager.getStateOfContentBlocker(withIdentifier: contentBlockerId, completionHandler: { (state, error) in
print("new ContentBlockerState - \(String(describing: state?.isEnabled))")
})
Is this an issue with iOS 15.4 or is there something else I have to do to get this working now.
Post not yet marked as solved
How do I change the background of My View controller in SafariExtensionViewController? I have My View, I need to somehow change its background, NSView, I attached a screenshot https://pastenow.ru/GQ58E
Post not yet marked as solved
I'm just starting out on my journey, but please don't swear too much. Can you please tell me how to set the desired background color for Custom View, the color I need is #F8F7F7.
Post not yet marked as solved
I am facing an issue with browser extension. extension stops working if we keep the browser idle for overnight.
This happens on MacOS as well as iOS device.
Post not yet marked as solved
I am trying to develop a Safari Extension that can save a file from a webpage into persistent storage with minimal user input.
Problem
I don't know how to code it so that it results like manually saving a file from the "Sources" tab in Safari Web Inspector.
Equivalent manual steps
show source or resources of page
by keying ⌥⌘U or ⌥⌘A
or by navigating to Web Inspector then "Sources"
save the file
by selecting the file then by keying ⌘S
or by secondary clicking the file then clicking "Save File"
Alternative solution
Javascript get the URL of files from the HTML elements and then pass the URL to a downloader, but I don't want to download it after the browser already did. I want to save the already downloaded temporary files to reduce network trafficking.
Theory
From my current understanding, when a webpage is viewed, Safari downloads the files and loads them in memory.
Other
I tried multiple ways to Google it but I keep getting only unrelated results.
Thank you for your time to read this and in advance.
Post not yet marked as solved
How to download this file and fix safari browser when iPhone 8 is out of storage space…
file:///private/var/mobile/Containers/Shared/AppGroup/3F4D1382-DC26-4CA5-8836-00458AE0A389/File%20Provider%20Storage/Downloads/39PIWDCm.download
Post not yet marked as solved
I am using safari content blockers to block & unblock specific elements of a website when a user toggles on/off. I was assuming that when user toggles the blocking off & I remove blockings from blockers.json & then do a reload
class func reloadContentBlocker(withIdentifier identifier: String,
completionHandler: ((Error?) -> Void)? = nil)
the user would no longer see the blocks on safari. However, the user still sees unless he/she refreshes the page which doesn't seem the be the best user experience & it'd be annoying to remind user to do so every time. Are there any work arounds to this? Did Apple forgot to add this last step?
if we could've reloaded safari itself using swift it would've done the job but I am not aware of such APIs.
Really appreciate your help.
In Safari AppExtensions we have this API made available
https://developer.apple.com/documentation/safariservices/sfsafariextensionhandling/3238030-contentblocker?changes=_8__2
optional func contentBlocker(withIdentifier contentBlockerIdentifier: String, blockedResourcesWith urls: [URL], on page: SFSafariPage)
Is there something made available to WebExtension given WebRequest blocking isn't available in Safari.
Post not yet marked as solved
I have the Zoom for outlook on my Outlook account.
It works great on the Chrome, but when I try to add a zoom to a meeting in the calendar in Safari, I get into an endless loop of Allow screen, entering my company domain and again and again.
Post not yet marked as solved
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()
Post not yet marked as solved
I just converted a chrome extension with XCode command line
xcrun /Applications/Xcode-beta.app/Contents/Developer/usr/bin/safari-web-extension-converter /Users/macminitwo/Downloads/new-tab-background
which had no icon in manifest, after conversion there was build error
error: Build input file cannot be found: '/Users/macminitwo/camo theme/Shared (App)/Resources/Icon.png' (in target 'camo theme (iOS)' from project 'camo theme')
Then I updated manifest.json of main project and added icon to the project
"icons": { "16": "icon16.png", "48": "icon48.png", "128": "icon128.png" }
tried converting again, and it still gave same error.
Now, I have to manually put the icon in "resources" folder.
Note: every time on conversion, it said abort trap 6
What should I do to not get this error? And have icon there already.
System Info:
macOS: 11.4 Big Sur
XCode: 13.0 beta 3
Post not yet marked as solved
Hello,
I tried to convert an existing Chrome extension that uses alarms API. When you load the package in developper mode, you can put a "PeriodInMinute" under 1 and it triggers the alarm correctly.
In safari, after running in Xcode the converted App, the Alarms seems to be triggered only each minute.
Is there a way to allow alarms to be triggered under 1 minutes using Safari ?
Thanks !
According to https://developer.apple.com/documentation/safariservices/safari_web_extensions/assessing_your_safari_web_extension_s_browser_compatibility, tabs.onUpdated should be fully supported. However, I have noticed that the changeInfo only contains 'status'. This is insufficient because it does not give enough information what has actually changed on a tab.
For example, 'url' is expected to be in the changeInfo if tab's URL has changed. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated#changeInfo.
Note: already submitted a feedback to Safari via apple standard feedback channel. Don't know what will happen with that as I have never heard anything back from Apple. Coming from Microsoft platform, I find Apple awkwardly unreachable. And they don't provide enough information on their documentation. Do you guys share the same feelings? or it's just me.