This lib can work for highlight keywords or more.
// @require https://greasyfork.org/scripts/32209-stringsearchermap/code/StringSearcherMap.js
let map = new StringSearcherMap();
map.add('50', 1);
json_equals(map.match('8504'), [
{ type: 0, text: '8' },
{ type: 1, text: '50', data: 1 },
{ type: 0, text: '4' }
]);