Skip to content

Instantly share code, notes, and snippets.

@broofa
Created September 12, 2017 16:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save broofa/2d4a4e8e2dab05eac22d2e8acd4b591c to your computer and use it in GitHub Desktop.
Save broofa/2d4a4e8e2dab05eac22d2e8acd4b591c to your computer and use it in GitHub Desktop.
Bookmarklet for Go To Line in Chrome "view-source" pages
// Instructions
// 1. Go to Chrome -> Bookmarks -> Bookmarks Manager
// 2. Right-click Bookmarks Bar -> "Add Page ..."
// 3. Enter "Go To Line" for Name
// 4. Copy/paste the code below into URL (From-and-including "javascript:" to "void 0;"
//
// Now on any "view-source:..." page in Chrome, click the Bookmarks -> Go To Line menu
// item to scroll to and highlight the line of your choice
// -----
javascript:
var lineno = prompt('Go To Line');
document.querySelectorAll('td.line-number').forEach(function(el) {
var isLine = el.getAttribute('value') == lineno;
if (isLine) el.scrollIntoView();
el.parentElement.style.backgroundColor = isLine ? '#ff0' : 'inherit';
});
void 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment