Skip to content

Instantly share code, notes, and snippets.

@kenglxn
Last active October 18, 2018 08:28
Show Gist options
  • Save kenglxn/7c53b2ddf228f29f36817ac87db94740 to your computer and use it in GitHub Desktop.
Save kenglxn/7c53b2ddf228f29f36817ac87db94740 to your computer and use it in GitHub Desktop.
bookmarklet for søk i aurora console
javascript:(function () {
document
.querySelector('.user-profile p')
.appendChild(document.createElement('input'))
.addEventListener('keyup', (ev) => {
if (ev.target.value.length === 0) {
document.querySelectorAll('.console-table th, .console-table td').forEach(elem => (elem.style.display = ''));
}
if (ev.target.value.length > 2) {
const indexes = Array.from(document.querySelectorAll('.console-table thead th').entries()).filter(([idx, elem]) => elem.innerText.includes(ev.target.value)).map(([idx, elem]) => idx);
document.querySelectorAll('.console-table tr').forEach(row => {
Array.from(row.querySelectorAll('td,th').entries()).forEach(([idx, elem]) => {
elem.style.display = (idx === 0 || indexes.includes(idx)) ? '' : 'none';
})
});
}
});
}());
@bentsolheim
Copy link

Disse er ganske fine! Du får ikke nok cred for dem ;)

@kenglxn
Copy link
Author

kenglxn commented Oct 18, 2018

Modifisert versjon for nye aurora konsoll:

javascript:(function () {
  document
    .querySelector('.g-header-user')
    .appendChild(document.createElement('input'))
    .addEventListener('keyup', (ev) => {
      if (ev.target.value.length === 0) {
        document.querySelectorAll('table th, table td').forEach(elem => (elem.style.display = ''));
      }
      if (ev.target.value.length > 2) {
        const indexes = Array.from(document.querySelectorAll('table thead th').entries()).filter(([idx, elem]) => elem.innerText.includes(ev.target.value)).map(([idx, elem]) => idx);
        document.querySelectorAll('table tr').forEach(row => {
          Array.from(row.querySelectorAll('td,th').entries()).forEach(([idx, elem]) => {
            elem.style.display = (idx === 0 || indexes.includes(idx)) ? '' : 'none';
          })
        });
      }
    });
}());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment