-
-
Save peterflynn/ace5dd3d7a8ec645cd42 to your computer and use it in GitHub Desktop.
To use: create a new bookmark and paste into the URL field. | |
In Chrome, you can paste the full multiline code as shown below. | |
In other browsers, you may need to minify the code into one line first. |
javascript:(function() { document.querySelectorAll(".outdated-comment").forEach(function (node) { | |
node.classList.add("open"); | |
}) }()); |
// In the usual, simple case: | |
javascript:(function(){ document.querySelectorAll(".js-comment .author").forEach(function (node) { | |
if(node.textContent === "<YOUR USERNAME HERE>") { | |
for (var parent = node.parentNode; parent; parent = parent.parentNode) { | |
if (parent.classList && parent.classList.contains("outdated-comment")) { parent.classList.add("open"); break; } | |
} | |
} | |
}) }()); | |
// Or in my case I have two different usernames for GitHub vs. internal GH: | |
javascript:(function(){ document.querySelectorAll(".js-comment .author").forEach(function (node) { | |
if(node.textContent === "pflynn" || node.textContent === "peterflynn") { | |
for (var parent = node.parentNode; parent; parent = parent.parentNode) { | |
if (parent.classList && parent.classList.contains("outdated-comment")) { parent.classList.add("open"); break; } | |
} | |
} | |
}) }()); |
javascript:(function(){ | |
var start=new Date(prompt("Enter Date/Time", new Date())); | |
document.querySelectorAll(".js-comment relative-time").forEach(function (node) { | |
function closest(node, className) { | |
for (var parent = node.parentNode; parent; parent = parent.parentNode) { | |
if (parent.classList && parent.classList.contains(className)) return parent; | |
} | |
} | |
var border=closest(node, "js-comment"); | |
if (new Date(node.getAttribute("datetime")) >= start) { | |
border.style.border = "1px solid red"; | |
var container = closest(border, "outdated-comment"); | |
if (container) { container.classList.add("open"); } | |
} else { | |
border.style.border = ""; | |
} | |
}); | |
}()); |
javascript:(function(){ | |
function closest(node, className) { | |
for (var parent = node.parentNode; parent; parent = parent.parentNode) { | |
if (parent.classList && parent.classList.contains(className)) return parent; | |
} | |
} | |
var selectionNode = document.getSelection().anchorNode; | |
if (!selectionNode) { | |
alert("Select text in the file to go to parent blame for that file"); | |
return; | |
} | |
var fileBlock = closest(selectionNode, "file"); | |
var fileRelPath = fileBlock.getElementsByClassName("file-header")[0].dataset.path; | |
var parentSHABlock = document.querySelectorAll(".commit-meta .sha-block")[0]; | |
var parentSHANodes = parentSHABlock.querySelectorAll(".sha"); | |
if (parentSHANodes.length > 1) { | |
alert("Commit has two parents - unsure which to use"); | |
return; | |
} | |
var commitURL = parentSHANodes[0].href; | |
var url = commitURL.replace("/commit/", "/blame/") + "/" + fileRelPath; | |
/* Get line number */ | |
var codeCell = closest(selectionNode, "blob-code"); | |
var lineNumCell = codeCell.previousElementSibling; | |
var lineNum = lineNumCell.dataset.lineNumber; | |
url += "#L" + lineNum; | |
/* Navigate to new page */ | |
window.location.href = url; | |
}()); |
As of 2020-04-02, the class container name and HTML property have changed. It's now "object.open = true;" and ".js-resolvable-timeline-thread-container" as the class selector.
document.querySelectorAll(".js-resolvable-timeline-thread-container").forEach(function (node) {
node.open = true;
}) }());
To get to the logged in user name, this works, though not sure how stable it is: document.querySelector(".user-profile-link").href.replace(/.*\//, "")
The snippets from Expand All My Comments.js
don't work for me. I actually don't see any elements with a class name "outdated-comment"
, so perhaps the interface has changed, so I cooked up an alternative and got this working: https://gist.github.com/haridsv/6b902e3d1a5eb4f4496ef517d56b1f93
@cbowns 's answer works as of 27 aug 2020, but you need to wrap it in a javascript block like this:
javascript:(function() { document.querySelectorAll(".js-resolvable-timeline-thread-container").forEach(function (node) {
node.open = true;
}) }());
THANK YOU @peterflynn and @cbowns and @yngvark. ⬆️ this is it. See @yngvark's comment just above.
I added that to my gist here: https://gist.github.com/ElectricRCAircraftGuy/0a788876da1386ca0daecbe78b4feb44
@peterflynn FYI I forked and added this, feel free to add it to your gist if you find it useful. 😄