Skip to content

Instantly share code, notes, and snippets.

@james-s-tayler
Last active November 24, 2019 00:23
Show Gist options
  • Save james-s-tayler/4370ccfbfd47c031f923e0a26e4e0ef9 to your computer and use it in GitHub Desktop.
Save james-s-tayler/4370ccfbfd47c031f923e0a26e4e0ef9 to your computer and use it in GitHub Desktop.
viewedFiles.forEach(viewedFile => {
const currentFile = document.querySelectorAll(`div[data-path="${viewedFile.path}"]`)[0] || undefined;
if(currentFile) {
let currentDiffstat = currentFile.querySelectorAll("span.diffstat")[0].getAttribute('aria-label');
let match = viewedFile.diffstats === currentDiffstat;
console.log(`match: ${match} - ${viewedFile.path} - viewedDiffstat: ${viewedFile.diffstats}, currentDiffstat: ${currentDiffstat}`);
if(match) {
let checkbox = currentFile.querySelectorAll('input[type="checkbox"]')[0];
let viewed = checkbox.checked || false;
if(!viewed) {
checkbox.click();
console.log('changed to viewed!');
} else {
console.log('already is viewed!');
}
}
} else {
console.log(`match: skipped - ${viewedFile.path}`);
}
});
const diffHeaders = [...document.querySelectorAll("div.file-header")].map(node => (
{
path: node.attributes['data-path'].value,
diffstats: node.querySelectorAll("span.diffstat")[0].getAttribute('aria-label')
})
);
//run the diff-headers script to dump the list of viewed files into an array
//perform the actions stated here to transfer the data to another open PR
//run the dedupe script to mark as 'viewed' all the files that have matching pathnames + diffstats
JSON.stringify(diffHeaders);
switch tab ->
const diffHeaders = ... ctrl+v to paste the raw json, delete the outer most quotes and surround by ``
const viewedFiles = JSON.parse(diffHeaders);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment