Created
September 12, 2017 16:11
-
-
Save broofa/2d4a4e8e2dab05eac22d2e8acd4b591c to your computer and use it in GitHub Desktop.
Bookmarklet for Go To Line in Chrome "view-source" pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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