Skip to content

Instantly share code, notes, and snippets.

// This is the object that once its state changes,
// it will notify all the observers.
function Observable() {
this.observersList = [];
}
Observable.prototype.addObserver = function(observer) {
this.observersList.push(observer);
}
Observable.prototype.removeObserver = function (observer) {
var self = this;
function Pubsub() {
this.events = {};
}
Pubsub.prototype.publish = function(event, args) {
if (!this.events[event]) {
return false;
}
var subscribers = this.events[event];
@bboy114crew
bboy114crew / README.md
Created May 10, 2023 05:21 — forked from tuanchauict/README.md
Attach a stopwatch to Leetcode

This script attaches a stopwatch into the toolbar of Leetcode's problem page.

The feature is simple:

  • Start/Stop the stopwatch
  • Auto start after 2 mins remaining on the problem
  • Restore unstopped stopwatch for the next visit on the problem

Use this script with any browser extension allowing attaching JS to the page. (I use User JavaScript and CSS)