Skip to content

Instantly share code, notes, and snippets.

@jun66j5
Created July 30, 2020 14:39
Show Gist options
  • Save jun66j5/dd669a75a6f386fa1b829f01b95f3506 to your computer and use it in GitHub Desktop.
Save jun66j5/dd669a75a6f386fa1b829f01b95f3506 to your computer and use it in GitHub Desktop.
javascript:(function(b,k,e,l,s) { b = document.body; k = new Set(); e = function(event) { var m = /^\w[\w\d]*/.exec(event.target.textContent); if (m) b.className += ' x-highlight-' + m[0]; }; l = function(event) { var m = /^\w[\w\d]*/.exec(event.target.textContent); if (m) b.className = b.className.replace(' x-highlight-' + m[0], ''); }; document.querySelectorAll('dl em, dl span.pre').forEach(function(node) { var m = /^\w[\w\d]*/.exec(node.textContent); if (m) { node.className += ' x-highlight-' + m[0]; node.addEventListener('mouseenter', e); node.addEventListener('mouseleave', l); k.add(m[0]); } }); s = document.createElement('style'); k = Array.from(k.keys()); s.textContent = k.map(v => 'body.@ .@'.replace(/@/g, 'x-highlight-' + v)) .join(', ') + ' { background-color: lightgreen }'; b.appendChild(s); })()
(function(b,k,e,l,s) {
b = document.body;
k = new Set();
e = function(event) {
var m = /^\w[\w\d]*/.exec(event.target.textContent);
if (m)
b.className += ' x-highlight-' + m[0];
};
l = function(event) {
var m = /^\w[\w\d]*/.exec(event.target.textContent);
if (m)
b.className = b.className.replace(' x-highlight-' + m[0], '');
};
document.querySelectorAll('dl em, dl span.pre').forEach(function(node) {
var m = /^\w[\w\d]*/.exec(node.textContent);
if (m) {
node.className += ' x-highlight-' + m[0];
node.addEventListener('mouseenter', e);
node.addEventListener('mouseleave', l);
k.add(m[0]);
}
});
s = document.createElement('style');
k = Array.from(k.keys());
s.textContent = k.map(v => 'body.@ .@'.replace(/@/g, 'x-highlight-' + v))
.join(', ') +
' { background-color: yellow }';
b.appendChild(s);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment