Skip to content

Instantly share code, notes, and snippets.

@notthatnathan
Last active April 19, 2016 14:36
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 notthatnathan/98a77aed188db3f0c2d6 to your computer and use it in GitHub Desktop.
Save notthatnathan/98a77aed188db3f0c2d6 to your computer and use it in GitHub Desktop.
Style old Github issues
var how_far_back = 60; //time in days
var css = '.old-issue { background-color: #ddd; opacity: 0.1; filter: blur(2px); -webkit-filter: blur(2px); }'; //your css
// don't edit below!
var $rows = document.querySelectorAll('.js-issue-row'); //all issues
//check for old issues
for (var i = 0, l = $rows.length; i < l; i++) {
var current_time = new Date();
var $issue = $rows[i];
var $issue_time = $issue.getElementsByTagName('relative-time');
var issue_time = new Date($issue_time[0].getAttribute('datetime'));
current_time.setDate(current_time.getDate() - how_far_back);
if (issue_time < current_time) {
$issue.className += ' old-issue';
}
}
// insert stylesheet in head
var $head = document.head || document.getElementsByTagName('head')[0];
var $style = document.createElement('style');
$style.type = 'text/css';
if ($style.styleSheet){
$style.styleSheet.cssText = css;
} else {
$style.appendChild(document.createTextNode(css));
}
$head.appendChild($style);
@notthatnathan
Copy link
Author

Use CJS or another extension to run this script automatically when on github.com.

Requires jQuery, which Github is already including.

Usage

  • Change how_far_back to the number of days back that you consider "old" or "outdated." Default: 60
  • Change css to your desired styles. Default: blurred

image

@notthatnathan
Copy link
Author

Updated:

  • Removed jQuery requirement
  • Handles Github's change from time element to relative-time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment