SkillAgentSearch skills...

Qso

A MutationObserver like API for CSS selectors.

Install / Use

/learn @WebReflection/Qso
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Deprecated: QuerySelectorObserver

Please use qsa-observer instead, as it's been used in various other libraries, hence it's way more battle-tested, and better, than this initial attempt.


100% inspired by a Daniel's hack, this module brings a friendly MutationObserver like API to observe CSS selectors instead.


const so = new QuerySelectorObserver(records => {
  for (const record of records) {
    if (record.addedNodes.length) {
      record.target.textContent = 'Hello via QSO!';
      console.log(record.addedNodes);
    } else {
      console.log(record.removedNodes);
    }
  }
});

so.observe('.some-selector');
so.observe('#some-complex > .selector + p.cool');

button.onclick = () => so.disconnect();

Compatible with IE11 and other browsers, feel free to test it live.

Related Skills

View on GitHub
GitHub Stars32
CategoryDevelopment
Updated1y ago
Forks0

Languages

JavaScript

Security Score

75/100

Audited on Nov 3, 2024

No findings