Skip to content

Instantly share code, notes, and snippets.

@malys
Created January 16, 2026 16:47
Show Gist options
  • Select an option

  • Save malys/2c9ced39b14875711ec5a96ed8957276 to your computer and use it in GitHub Desktop.

Select an option

Save malys/2c9ced39b14875711ec5a96ed8957276 to your computer and use it in GitHub Desktop.
[Filter Glance] #userscript #glance
// ==UserScript==
// @name Glance filter
// @namespace Violentmonkey Scripts
// @match https://glance.l.malys.ovh/*
// @grant none
// @version 1.0
// @author -
// @description 04/11/2025 20:06:32
// ==/UserScript==
(function () {
'use strict';
// === Create floating search input ===
const input = document.createElement('input');
Object.assign(input.style, {
position: 'fixed',
top: '1rem',
right: '1rem',
width: '250px',
padding: '8px 10px',
fontSize: '14px',
borderRadius: '6px',
border: '1px solid #888',
background: '#222',
color: '#fff',
zIndex: '9999',
display: 'none',
});
input.placeholder = 'Filter bookmarks...';
document.body.appendChild(input);
// === Helper selectors ===
const allLinks = () => Array.from(document.querySelectorAll('.bookmarks-link'));
const allGroups = () => Array.from(document.querySelectorAll('.bookmarks-group'));
// === Filtering logic ===
const filter = (query) => {
const q = query.toLowerCase().trim();
allGroups().forEach(group => {
let anyVisible = false;
const links = group.querySelectorAll('.bookmarks-link');
links.forEach(link => {
const match = link.textContent.toLowerCase().includes(q);
link.closest('li').style.display = match ? '' : 'none';
if (match) anyVisible = true;
});
group.style.display = anyVisible ? '' : 'none';
});
};
// === Keyboard events ===
document.addEventListener('keydown', (e) => {
// Open search with `/`
if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey) {
e.preventDefault();
input.style.display = 'block';
input.focus();
input.select();
}
// Close with Esc
else if (e.key === 'Escape') {
input.value = '';
input.style.display = 'none';
filter('');
}
// When input visible and Enter pressed → open first visible link
else if (input.style.display === 'block' && e.key === 'Enter') {
const visibleLink = allLinks().find(l => l.closest('li')?.style.display !== 'none');
if (visibleLink) {
window.open(visibleLink.href, '_blank');
}
}
});
// === Live filtering ===
input.addEventListener('input', () => filter(input.value));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment