Giter Club home page Giter Club logo

adguardforsafari's Introduction

 

AdGuard for Safari

The most advanced ad blocking extension for Safari

Free and open source, highly customizable and lightning fast ad blocking extension.

AdGuard.com | Reddit | Twitter | Telegram

Download on the AppStore Latest release Latest beta



AdGuard for Safari

Ad blocking extensions for Safari are having hard time since Apple started to force everyone to use the new SDK. AdGuard extension is supposed to bring back the high quality ad blocking back to Safari.

Unlike other major ad blockers, AdGuard provides some extra features you are used to have with the traditional (now deprecated) extensions:

  • Managing protection from Safari
  • Choose among popular filter subscription
  • Custom filters
  • Creating your own filtering rules
  • Manual blocking tool
  • Allowlisting websites

AdGuard for Safari is based on the Safari native content blocking API, which makes it lightning fast, but somewhat limited in capabilities. For instance, Safari limits the number of rules a content blocker can have.

Better yet, there is a full-fledged AdGuard for Mac

With all above said, there is a solution that is even more effective than AG Safari extension. I mean, of course, AdGuard for Mac. It can:

  • filter your traffic in all browsers and apps on your Mac
  • have an unlimited number of filter rules
  • provide a better filtering quality (due to the lack of browser API restrictions)

You can try it out for free.

How to build AdGuard for Safari

AdGuard for Safari consists of three parts:

  • An Electron application.
  • Safari Content Blocker extension
  • Safari Toolbar icon extension

Prerequisites

  • MacOS 13.1 or above
  • Xcode 14.3 or above
  • Xcode Command Line Tools
  • Node.js v18.17.1 or higher
  • Yarn
  • JQ

Also, you need to install these packages globally:

yarn global add electron-packager
yarn global add node-gyp
yarn global add electron-osx-sign

How to build

To run application in development mode

cd ElectronMainApp

Install local dependencies by running:

yarn install

How to debug the app

Debug window

Launch the application via:

yarn start

Open menu View -> Toggle Developer Tools

Debug main process

Launch the application via

yarn inspect

Open URI chrome://inspect in Chromium

Then add a network target localhost:5858 via button "Configure" and select this target below.

Build and run in production mode

Replace the following line in file ./AdGuard/Config.xcconfig

AG_SIGN = <YOUR APPLE DEVELOPER COMMON NAME>

where <YOUR APPLE DEVELOPER COMMON NAME> is your codesign identity

Make sure your system Nodejs version higher v8.9.4.

Steps to check it: if you use nvm run

nvm use system
node -v

otherwise

node -v

Open AdGuard.xcworkspace in Xcode and run building project

How to run tests

cd ElectronMainApp
yarn test

Preparing and building Adguard.

Environment requirements

  • MacOS 13.1+
  • Xcode 14.3+
  • Install Xcode command line tools
xcode-select --install
  • Install the ruby module bundler if it is not in the system
sudo gem install bundler
  • Fastlane manages development and distribution certificates according to the documentation described in fastlane match. The file ./fastlane/env.default contains variables (SENSITIVE_VARS_PATH, APP_STORE_CONNECT_API_KEY_PATH) that define the paths to files with private information necessary for fastlane match to work. Create these files in a hidden location with the appropriate contents and specify their paths in the these variables.
  • You need to run the configure.sh dev script, which will install the necessary components and certificates locally.
cd <repository>
./configure.sh dev

Check certificates names in Scripts/ExportOptions.plist

Building

SafariConverterLib dependency

For converting rules to content-blocker format we use an external library as a binary built from https://github.com/AdguardTeam/SafariConverterLib/, that ConverterTool binary should be placed in ./libs/.

You use ./Scripts/download-lib.sh to download the latest release version of that binary from Github.

Common issues

https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution/resolving_common_notarization_issues

Use fixed electron-osx-sign

npm install -g electron-userland/electron-osx-sign#timestamp-server

How to release standalone builds

  • update version package.json and AdGuard/standalone.xcconfig or AdGuard/standalone-beta.xcconfig
  • build apps
  • notarize builds
  • publish release on Github
  • refresh updates/updates.json and release.json in gh-pages branch

Build application

./build.sh <channel> [--notarize=0]

Arguments:

  • <channel> -- updates channel:
    • mas -- Mac App Store
    • beta -- standalone beta
    • release -- standalone release
  • [--notarize=0] -- optional parameter to skip notarization

Output directory build contains:

  • Adguard for Safari.app -- signed and notarized app.
  • Adguard for Safari.app.zip -- zip of signed and notarized app.
  • Adguard for Safari.xcarchive -- app archive.
  • Adguard for Safari.xcarchive.zip -- zip of app archive
  • version.txt -- version info (CI requirement).
  • updates.json -- json file with updates info.
  • release.json -- json file with updates info.

Clean install

  • Disable all AdGuard for Safari extensions in Safari browser settings and close browser
  • Close AdGuard for Safari
  • Delete the following directories:
    • ~/Library/Application Support/AdGuardSafariApp
    • ~/Library/Containers/ - all directories started with com.adguard.safari.AdGuard (if there’s any)
    • ~/Library/GroupContainers/TC3Q7MAJXF.com.adguard.safari.AdGuard
    • ~/Library/Preferences/com.adguard.safari.AdGuard.plist
  • Quit all “AdGuard” and “cfprefsd” processes in Activity monitor
  • Reinstall AdGuard for Safari

adguardforsafari's People

Contributors

ameshkov avatar artembaskal avatar birbber avatar ferdi2005 avatar maximtop avatar mizzick avatar slavaleleka avatar stanislav-atr avatar stillness-2 avatar thehasagi avatar tvinzz avatar versty avatar vozersky avatar zebrum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adguardforsafari's Issues

Safari App Extensions metadata

Toolbar Icon

Name = AdGuard Safari Icon
Description = You can use this icon to manage AdGuard for Safari settings. For instance, pause blocking on a website, or block an ad manually.

Content Blocker

Name = AdGuard
Description = Fast and lightweight Safari content blocking extension.

Implement the onboarding screen

Screenshot: https://uploads.adguard.com/up04_d73e0_Ext.sketch.png

  • Full info is in the Sketch file (the image must be updated accordingly with #12)
  • You'll need @kaprielov's help with the markup.

Here's how it should work.

  1. When the toolbar icon is disabled OR when the content blocker is disabled, you should show this onboarding screen instead of the main extension UI.
  2. This is not just about the first install. Any time when any of the necessary extensions are disabled, we must react and show this screen.
  3. Once both extensions are enabled, navigate to settings automatically, don't make the user wait.

Tooltip under container

Steps to reproduce

  1. Open Filters
  2. Open Group (e.g Ad Blocking)
  3. Move mouse over a tag in the last elem in list

Screen Shot 2018-09-26 at 15.38.01.png

Preparing the app to be published to Mac AppStore

Figure out the following:

  • How to prepare the app to be published to Mac AppStore
  • Is it possible to have a beta tester's channel there? If not, what are the options for beta testers?
  • What metadata do we need to supply in order to get the app published. Post the list here, we'll start preparing it.

Initial app translations

@timirila1 please work with @aalpatkina and prepare a shortlist of languages we will have on the initial release (I suggest English, German, and Russian at least).

Also, we need to update the oneskyapp project and upload the app screenshots there.

User Filter rules applying take some time

Steps

  1. Open any site (e.g. example.org)
  2. Open Safari Extension in toolbar
  3. Select area to block on site
  4. Refresh page

Expected:
Selected area not visible

Actual:
Selected area on it's place

Filter groups must have their own status

The current logic is based on what filters are enabled. This is wrong, filter groups must have their own status.

Here's how it must work:

  1. When the filter group is enabled for the first time, we must also enable all filters with the recommended tag and matching the lang tag (if it is specified).
  2. We no more do it afterward, even when the user switches the filter group status on or off.

Whitelist/Inverted whitelist editors bug

  1. Open Whitelist, type some domains
  2. Turn on Inverted whitelist
  3. Type something
  4. Press cmd+z several times until whitelist editor appears.

How Whitelist and Inverted whitelist editors connected?

Two filters update messages

  1. Add custom filter
  2. Check filter updates

Actual behaviour: It shows 2 notifications - one about AG filters (were updated or not) and other about Custom filter was updated, even if there was no update for it.

JS Error when add Custom Filter

Steps

  1. Open Filters section
  2. Click on Custom and Add custom filter
  3. Add any valid url to filter or https://easylist-downloads.adblockplus.org/easylist.txt
  4. Next -> (wait) -> Subscribe
Uncaught Exception:
TypeError: Cannot read property 'enabled' of undefined
    at Object.groupHasEnabledStatus (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters/subscriptions.js:414:29)
    at enableFilter (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:146:28)
    at /Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:205:25
    at onFilterLoaded (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:172:13)
    at addAntiBannerFilter (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:176:13)
    at loadNextFilter (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:203:17)
    at Object.addAndEnableFilters (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/app/filters-manager.js:213:9)
    at EventEmitter.<anonymous> (/Users/timshenin/adguard/safari-app-extension/ElectronMainApp/src/main/ui-event-handler.js:33:25)

Can't add custom filter by url

  1. go to Settings - Filters - Custom - Add custom filter
  2. add link to a custom filter, press Next

Actual behaviour: app hangs on Checking your filter

Update the localization scripts

Create a new project on adguard.oneskyapp.com:

  • Project group=Adguard Browser Extensions

  • Name="AdGuard for Safari".

  • Also, add download/upload localization scripts

  • Don't forget about the native part of the code

  • Add a script that scans the extension code and searches for redundant strings there

Divide UI into separate components

I noticed some performance issues when UI repaint. Also it can be difficult to maintain the project when it will become larger.

I suppose we may use React to break UI into components.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.