Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YTSTAB

hellow :3, it me again, your favorite femboy dev with another (def) banger, now introducin YTSTAB or Your Typical Scramjet Ad Blocker, its just an ad blocker mod for Scramjet v1.1.0, we will add v2 version eventually when i have time not working with Lunar OS. its also on npm now btw, as @crateredlabs/ytstab. if you want anything added, tell me in the official Cratered Labs Discord Server. (Update, YOU CAN INSTALL YTSTAB AS A NPM PACKAGE, CHECK INSTRUCTIONS.md

Information

YTSTAB is a single-file Scramjet Ad Blocker Mod, thats it, it blocks 200+ domains, split into categories now so u can turn specific ones off/on instead of all or nothing.

YTSTAB's, STAB Process (yes im so clever)

  1. STAB fetches every request from the server SW usually gets
  2. Decodes the Scramjet URL into an actual URL it can reads
  3. Checks its hostname and sub-domain and matches it to a category in STAB's list
  4. If it matches AND that category is turned on, it gives the 204 Empty Response and never reaches the server
  5. if it doesn't match, or the category its in is turned off, it lets it though the wall and goes to the server and goes to your user

Setup

option A, copy the file

  1. Copy the file into your project, wherever your Scramjet service worker is served from.

  2. Match the prefix. Open the file and check the PREFIX constant near the top — it must match exactly the prefix you passed into your ScramjetController on the client side:

   const controller = new ScramjetController({ prefix: "/scramjet/service/" });
  1. Use the default codec. Make sure your ScramjetController isn't passing a custom codec option. This file decodes proxied URLs with plain decodeURIComponent, matching Scramjet's default — a custom codec will break the decoding.

  2. Register it the way you'd register any Scramjet service worker, at the same scope as your prefix:

   await navigator.serviceWorker.register("/scramjet.sw.js", { scope: "/scramjet/service/" });

option B, npm

npm install @crateredlabs/ytstab

it wont just work after installing tho, npm just dumps the file in node_modules, u still gotta copy it into ur public folder and do steps 2-4 above. check INSTRUCTIONS.md in the package if u forget how.

Runtime Controls

STAB can also be turned off and on, whole thing or just one category, all through postMessage. state also actually sticks now (saved in IndexedDB) so it wont randomly reset when the browser kills the service worker in the background

turning it all on/off:

const reg = await navigator.serviceWorker.getRegistration("/scramjet/service/");
reg.active.postMessage({ type: "YTSTAB_SET", enabled: true }); // put false to turn it off

turning off just one category:

reg.active.postMessage({ type: "YTSTAB_SET_CATEGORY", category: "ads", enabled: false });

asking for current state (good for loadin ur settings page correctly instead of guessin):

reg.active.postMessage({ type: "YTSTAB_GET_STATE" });

listening for state + blocked hits:

navigator.serviceWorker.addEventListener("message", (e) => {
  if (e.data?.type === "YTSTAB_STATE") {
    console.log("current state:", e.data.on, e.data.categories, e.data.categoryList);
  }
  if (e.data?.type === "YTSTAB_HIT") {
    console.log("blocked:", e.data.url, "category:", e.data.category);
  }
});

all of this is needed or YTSTAB will be ass for your users

Editing the STAB list

go to scramjet.sw.js (aka the single file) and find const CATEGORIES, its an array of category objects like this:

{
  id: "ads", label: "Ads",
  domains: [ "adzerk.com", "adroll.com", ... ],
}

just add/remove domains inside whichever category's domains array, or make a whole new category object if it doesnt fit existing ones. follow the format and it wont break.

Known Limitations

  1. STAB only blocks stuff going through your Scramjet proxy's prefix, it doesn't touch your site's own direct asset loads, thats on purpose, its not meant to be a full site-wide ad blocker, just a proxy one
  2. Right now STAB can't tell the difference between navigatin straight to a blocked domain vs a blocked subresource, so if u go directly to one you'll just get a blank page instead of somethin that actually tells you its blocked, contributions welcome here if anyone wants to fix that

Extra Info

If you want v2 beta version, idk dm me to do it or you merk me. :3 anyways, if you are using YTSTAB, thank you. >:D Plentfy, Femboy Dev and Owner of YTSTAB

About

Your Typical Scramjet Ad Blocker

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages