Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Benjaminhu/3388b4112eb071bb27b12185b9ac232c to your computer and use it in GitHub Desktop.
Save Benjaminhu/3388b4112eb071bb27b12185b9ac232c to your computer and use it in GitHub Desktop.
JavaScript Bookmarklet: get unique sorted pattern list from current HTML page
// steps:
// 1. copy code (CTRL + A, CTRL + C)
// 2. go to: http://subsimple.com/bookmarklets/jsbuilder.htm
// 3. paste code after: "javascript:"
// 4. [optional] customize "pattern"
// 5. add name
// 6. push "(function...)" button
// 7. push "comress" button
// 8. drag & drop your bookmarklet name to your bookmark tab
// AA-00 ... ZZZZZ+-99999+
var pattern = /([A-Z]{2,}\-\d{2,})/g;
function initPatternList(content) {
var match = content.match(pattern);
var uniquePatters = [...new Set(match)];
var patternList = uniquePatters.sort().join(', ');
alert(patternList);
}
initPatternList(document.documentElement.innerHTML);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment