View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • What’s new in Safari Web Extensions

    Learn how you can use the latest improvements to Safari Web Extensions to create even better experiences for people browsing the web. We'll show you how to upgrade to manifest version 3, adopt the latest APIs for Web Extensions, and sync extensions across devices.

    Recursos

    • Modernizing Safari Web Extensions
    • Messaging a Web Extension’s Native App
    • Developing a Safari Web Extension
    • Learn more about bug reporting
    • MDN Web Docs - Web Extensions API
    • Safari web extensions
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC23

    • What’s new in Safari extensions

    WWDC22

    • Create Safari Web Inspector Extensions
    • What's new in Safari and WebKit

    WWDC21

    • Explore Safari Web Extension improvements
  • Buscar neste vídeo...
    • 2:43 - Executing script on webpages

      // Manifest version 2
      browser.tabs.executeScript(1, {
        frameId: 1,
        code: "document.body.style.background = 'blue';"
      });
    • 3:00 - scripting.executeScript API

      // Manifest version 3
      function changeBackgroundColor(color) {
        document.body.style.background = color;
      };
      
      browser.scripting.executeScript({
        target: { tabId: 1, frameIds: [ 1 ] },
        func: changeBackgroundColor,
        args: [ "blue" ]
      });
    • 4:02 - tabs.executeScript file

      // Manifest version 2
      browser.tabs.executeScript({ 1,
        file: "file.js"
      });
    • 4:09 - scripting.executeScript API files

      // Manifest version 3
      browser.scripting.executeScript({
        target: { tabId: 1 },
        files: [ "file.js", "file2.js" ]
      });
    • 4:15 - scripting.insertCSS

      // Add styling
      browser.scripting.insertCSS({
        target: { tabId: 1, frameIds: [ 1, 2, 3 ] },
        files: [ "file.css", "file2.css" ]
      });
    • 4:21 - scripting.removeCSS

      // Remove styling
      browser.scripting.removeCSS({
        target: { tabId: 1, frameIds: [ 1, 2, 3 ] },
        files: [ "file.css", "file2.css" ]
      });
    • 5:08 - Manifest version 3 web_accessible_resources

      // Manifest version 3
      "web_accessible_resources": [
          {
            "resources": [ "pie.png" ],
            "matches": [ "*://*.apple.com/*" ]
          },
          {
            "resources": [ "cookie.png" ],
            "matches": [ "*://*.webkit.org/*" ]
          }
      ]
    • 5:42 - Manifest version 3 action

      // Manifest version 3
      "action": {
        "default_icon": {
          "16": "Images/icon16.png"
        },
        "default_title": "defaultTitle"
      }
    • 5:57 - Manifest version 2 content_security_policy

      // Manifest version 2
      
      "content_security_policy" : "script-src 'unsafe-eval' https://*apple.com 'self'"
    • 6:08 - Manifest version 3 content_security_policy

      // Manifest version 3
      
      "content_security_policy" : { "extension_pages" : "script-src 'unsafe-eval' 'self'" }
    • 10:31 - Specifying a ruleset

      // manifest.json
      
      "permissions": [ "declarativeNetRequest" ],
      
      "declarative_net_request": {
        "rule_resources": [
          {
            "id": "my_ruleset",
            "enabled": true,
            "path": "rules.json"
          }
        ]
      }
    • 11:44 - updateSessionRules

      // Rules that won't persist
      
      browser.declarativeNetRequest.updateSessionRules({ addRules: [ rule ] });
      
      // Rules that will persist
      
      browser.declarativeNetRequest.updateDynamicRules({ addRules: [ rule ] });
    • 14:33 - externally connectable

      // In the webpage
      let extensionID = "com.apple.Sea-Creator.Extension (GJT7Q2TVD9)";
      
      browser.runtime.sendMessage(extensionID, { greeting: "Hello!" },
       function(response) {
          console.log("Received response from the background page:");
          console.log(response.farewell);
      });
    • 15:00 - Message from webpage to extension (in the webpage)

      // In the webpage
      let extensionID = "com.apple.Sea-Creator.Extension (GJT7Q2TVD9)";
      
      browser.runtime.sendMessage(extensionID, { greeting: "Hello!" },
       function(response) {
          console.log("Received response from the background page:");
          console.log(response.farewell);
      });
    • 15:33 - Message from webpage to extension (in the background page)

      // In the background page
      browser.runtime.onMessageExternal.addListener(function(message, sender, sendResponse) {
          console.log("Received message from the sender:");
          console.log(message.greeting);
          sendResponse({ farewell: "Goodbye!" });
      });
    • 16:17 - Determining the correct identifier

      // Determining the correct identifier
      
      function determineExtensionID(extensionID) {
        return new Promise((resolve) => {
          try {
            browser.runtime.sendMessage(extensionID, { action: 'determineID' }, function(response) {
              if (response)
                resolve({ extensionID: extensionID, isInstalled: true, response: response });
              else 
                resolve({ extensionID: extensionID, isInstalled: false });
            });
          }
        });
      };
    • 17:09 - background.js

      // background.js
      
      browser.runtime.onMessageExternal.addListener(function(message, sender, sendResponse) {
        if (message.action == "determineID") {
          sendResponse({ "Installed" });
        }
      });
    • 18:07 - Unlimited storage

      // manifest.json
      
      "permissions": [ "storage", "unlimitedStorage" ]

Developer Footer

  • Vídeos
  • WWDC22
  • What’s new in Safari Web Extensions
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines