Post

Replies

Boosts

Views

Activity

How to take a screenshot of a tab
Hello, Is it possible to take a screenshot of a non-active tab? Firefox supports this via captureTab (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/captureTab) With Safari App extensions that was possible via getScreenshotOfVisibleArea which doesn't seem to work with Safari extensions.
1
0
637
Feb ’24
declarativeNetRequest.Redirect - Does Safari fully support it?
Hello, According to MDN, Safari v15.4+ should fully support declarativeNetRequest.Redirect, including regexSubstitution, but when I use it in a rule I get this: Rule: EXT_PAGE = '/hello.html'; RULES = [{ id: 1, action: { type: 'redirect', redirect: { regexSubstitution: EXT_PAGE + '#\\0' }, }, condition: { requestDomains: ['example.com'], regexFilter: '^.+$', resourceTypes: ['main_frame', 'sub_frame'], }, }]; browser.declarativeNetRequest.updateDynamicRules({ removeRuleIds: RULES.map(r => r.id), addRules: RULES, }); Error: Invalid call to declarativeNetRequest.updateDynamicRules(). Error with rule at index 0: Rule with id 1 is invalid. redirect is missing either a url, extensionPath, or transform key.
2
0
916
Jul ’23
Screenshot of non-active tab
Hello, Is it possible to take a screenshot of a non-active tab? Firefox supports this via captureTab (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/captureTab) With Safari App extensions that was possible via getScreenshotOfVisibleArea which doesn't seem to work with Safari extensions.
0
0
668
Oct ’21
Safari handles tabs created by app extensions and web extensions differently
Feedback ID: FB8176693 Hello, I have reported this before, but just noticed the behaviour is different in web extensions. Have an web extension create a new tab to open an HTML page inside the extension resources: browser.tabs.create({'url': browser.runtime.getURL("test.html") + '?p1=test&p2=test2' }); Now the equivalent in an app extension: SFSafariApplication.getActiveWindow { activeWindow in SFSafariExtension.getBaseURI { baseURI in guard let baseURI = baseURI else { return } var urlComponents = URLComponents(string: baseURI.appendingPathComponent("test.html").absoluteString); urlComponents?.queryItems = [ URLQueryItem(name: "p1", value: "test"), URLQueryItem(name: "p2", value: "test2"), ]; activeWindow?.openTab(with: (urlComponents?.url)!, makeActiveIfPossible: true, completionHandler: {_ in }); } } After the tab is created notice its URL, eg.: safari-extension://2CB967-22BA-44F3-B604-72611F/aafefbf/test.html?p1=test&p2=test2 Now, restart Safari. Expected: Restored tab shows the same url (minus the baseURL which has been updated) Actual: The tab created by the Safari app extension shows the updated baseURI without any parameters. Eg.: safari-extension://11111-new-baseURI-44F3-B604-72611F/o213s/test.html - The tab created by the Safari web extension shows the full url as expected Considering this is affecting a great number of my users and renders the extension pretty useless, I am wondering if there are any realistic plans to fix this? Moving to web extension might be very problematic as the extension requires access to all pages the user accesses and since most users are not very tech savvy it will be quite hard to guide them through the new permission prompts. Thank you
0
0
572
Nov ’20
browser.tabs API not working as expected
Here's my manifest.json: {   "manifest_version": 2,   "default_locale": "en",   "name": "MSG_extension_name",   "description": "MSG_extension_description",   "version": "1.0",   "icons": {     "48": "images/icon-48.png",     "96": "images/icon-96.png",     "128": "images/icon-128.png",     "256": "images/icon-256.png",     "512": "images/icon-512.png"   },   "background": {     "scripts": [ "background.js" ]   },   "content_scripts": [{     "js": [ "content.js" ],     "matches": [ "*://example.com/*" ]   }],   "browser_action": {     "default_popup": "popup.html",     "default_icon": {       "16": "images/toolbar-icon-16.png",       "19": "images/toolbar-icon-19.png",       "32": "images/toolbar-icon-32.png",       "38": "images/toolbar-icon-38.png"     }   },   "permissions": ["<all_urls>", "tabs"] } On my background.js, I have this: browser.tabs.onCreated.addListener(tab => {   console.log("onCreated", tab) }) browser.tabs.onCreated.addListener((tabId, changeInfo, tab) => {   console.log("onUpdated", tabId, changeInfo, tab) }) When I open a new tab I see this in the background log: "onCreated": { &#9;"id": 7, &#9;"index": 1, &#9;"active": true, &#9;"width": 938, &#9;"audible": false, &#9;"url": "", &#9;"mutedInfo": { &#9;&#9;"muted": false &#9;}, &#9;"windowId": 2, &#9;"title": "", &#9;"pendingUrl": "", &#9;"incognito": true, &#9;"pinned": false, &#9;"height": 1027, &#9;"highlighted": true, &#9;"status": "complete" } "onUpdated": { &#9;"id": 7, &#9;"index": 1, &#9;"active": true, &#9;"width": 938, &#9;"audible": false, &#9;"url": "", &#9;"mutedInfo": { &#9;&#9;"muted": false &#9;}, &#9;"windowId": 2, &#9;"title": "", &#9;"pendingUrl": "", &#9;"incognito": true, &#9;"pinned": false, &#9;"height": 1027, &#9;"highlighted": true, &#9;"status": "complete" } Problem 1 Why are the title, url and pendingUrl empty if I have the permission set for all urls and the user accepted it? Problem 2 Safari internal pages url, eg.: "about:blank" are not included in browser.tabs.query, eg.: browser.tabs.query({}, el => { console.log(el)})
1
0
1.2k
Sep ’20
Accessing extension url from iCloud
Hello, I have an extension that will do some processing on a website chosen by the user and then it will show a report in an extension's internal page, eg.: safari-extension://2CB967-22BA-44F3-B604-72611F/aafefbf/report.html?domain=wikipedia.org&tm=1600000000 There are 2 problems with this approach: If the user closes Safari, the next time they will open it (and Safari is set to open the previous session tabs), the extension's internal page will have its parameters stripped, it will open like this: safari-extension://1KP84U-KO31-00L1-M133-032P11/ksleif/report.html Notice the lack of query parameters. The extension's baseURI change is expected and is not an issue since Safari 14 updates the baseURI of the tab with the new baseURI of the extension If the user tries to open that report url in an iPhone or iPad, the page will fail to load as it is an extension's internal page. For point 1. I believe this is a bug? I've filled a report: FB8176693 For point 2. I have tried the following: Instead of using an extension's internal page, I encoded the full report's HTML and display in in data URI, eg.: data:text/html;charset=UTF-8,<span onclick=%22alert(%27test%27);%22>Hello</span> But iOS will not show any tabs from iCloud open that use the data protocol(?) iOS app that register's the safari-extension:// protocol. But I'm sure that would never get approved I guess it's also possible to open the report in my own website, but that would be a major privacy issue. Something that neither me nor my users would not feel comfortable with. Are there any other options? I feel like I hit a wall
1
0
592
Sep ’20
Unexpected(?) behaviour when loading an extension's internal URL
FB7597364 (attached video there) Hello, I have filled a radar but I'm wondering if I am misunderstanding the following (Safari TP 104+): Make the extension open a new tab with the baseURI and a parameter, eg.: safari-extension://2CB967-22BA-44F3-B604-72611F/aafefbf/test.html?title=Apple&amp;color=red Here's the code I'm using: SFSafariApplication.getActiveWindow { activeWindow in &#9;&#9;&#9;&#9;&#9;&#9;SFSafariExtension.getBaseURI { baseURI in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;guard let baseURI = baseURI else { return } &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;var urlComponents = URLComponents(string: baseURI.appendingPathComponent("test.html").absoluteString); &#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;urlComponents?.queryItems = [ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; URLQueryItem(name: "title", value: "Apple"), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; URLQueryItem(name: "color", value: "red"), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;]; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;activeWindow?.openTab(with: (urlComponents?.url)!, makeActiveIfPossible: true, completionHandler: {_ in }); &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} 2. Wait for the page to load 3. Quit Safari 4. Open Safari Expected: Safari updates the baseURL of that tab and keeps the query parameters, eg: safari-extension://11111-new-baseURI-44F3-B604-72611F/o213s/test.html?title=Apple&amp;color=red Actual: Safari updates the baseURL of that tab and strips the query parameters, eg: safari-extension://11111-new-baseURI-44F3-B604-72611F/o213s/test.html
7
1
1.9k
Jul ’20