kbin-mod-options; v0.3.0 - Now with observers!

Creating a new thread as I've moved instances and can no longer update the old one. Sorry about that!

kbin-mod-options

Description

The purpose of this script is to allow mod authors to more easily implement settings and features. Only new feature notes will be included in this document. To view usage, please refer to the README.

Patch Notes

  • 0.1.0 - Initial Release
  • 0.2.0 - Breaking change. By default, settings will be collapsed as a drawer.
    • 0.2.2 - Compatibility fix for KUP (Kbin Usability Pack) 0.2.1+.
    • 0.2.3 - Style changes + animations.
    • 0.2.4 - Bug-fix for Kbin/kbin-core#666.
  • 0.3.0 - New feature: Observers!

Observer

This is for making infinite scroll support easier for mod creators and not an actual setting module.

kmoCreateObserver({<funcToCall: yourFunctionNameHere>[, nodeType: 'id'][, nodeToWatch: 'content'][, watchSubtree: false]});

NOTE: You're passing an object here that allows for named arguments. Please review example closely.

  • funcToCall - required
  • nodeType - optional
  • nodeToWatch - optional
  • watchSubtree - optional

Example

// Create observer for main content feed.
cont myObserver = kmoCreateObserver({funcToCall: updateNewContent});
// Example function
function updateNewContent() {
    // Do stuff here
}
// Stop observing, maybe your addon is toggled off?
function shutdown() {
    myObserver.disconnect();
}

// Maybe you want to watch perry.dev's subscription panel list
const mySubObserver = kmoCreateObserver({funcToCall: subUpdate, nodeType: 'class', nodeToWatch: 'subscription-list'});
// Example function
function subUpdate() {
    // Do stuff here
}
// Stop observering - doesn't have to be in a function, but it makes life easier.
function shutdown() {
    mySubObserver.disconnect();
}

/kbin logotype
  • All
  • Subscribed
  • Moderated
  • Favorites
  • kbinStyles
  • DreamBathrooms
  • magazineikmin
  • Durango
  • cubers
  • Youngstown
  • rosin
  • khanakhh
  • slotface
  • osvaldo12
  • mdbf
  • thenastyranch
  • kavyap
  • InstantRegret
  • cisconetworking
  • megavids
  • everett
  • tester
  • ethstaker
  • Leos
  • tacticalgear
  • GTA5RPClips
  • ngwrru68w68
  • provamag3
  • normalnudes
  • anitta
  • modclub
  • JUstTest
  • lostlight
  • All magazines