How to add a new site - adsbypasser/adsbypasser GitHub Wiki

Scripts of each site are placed in src/sites. We have three categories of sites: file, image, and link. Please place the script into the right category.

If you want to add, which is a short-link site, you should create a script in src/sites/link/


  rule: {
    host: /example\.com$/,
  async ready () {
    let a = $('#skip');
    await $.openLink(a.href);

When you register a new handler for this site, AdsBypasser provides two convenient modules, _ and $, for writing less code.

You should register handler by _.register, which takes an object as an argument. In this example, we give it two properties: rule and ready.

rule describes how to match this site. In this example, it is an object with host property, which means that location.hostname must match the given regular expression. For more information about how to write rule, please see URL pattern.

ready describes what actions should be done when the matched page has been parsed. You could use $ to grab HTML element on the page. $ supports CSS3 selector.

Once you find out the URL you want, you could use $.openLink to redirect to the URL.

Avoid name conflict

You can register two or more handlers in one file. But if you need to define new variable outside the handlers, wrap them into a function scope.

For example:

(function () {
  'use strict';

  async function commonRunner () {
    // do something

    rule: /first pattern/,
    ready: commonRunner,

    rule: /second pattern/,
    ready: commonRunner,

Build scripts

Please see How to build and test scripts.