<commit_before>// Scans your stylesheet for pseudo classes and adds a class with the same name.
// Thanks to Knyle Style Sheets for the idea.

(function() {

var pseudoRe = /(\:hover|\:focus|\:disabled|\:active|\:visited)/g;

var toArray = function(obj) {
  return Array.prototype.slice.call(obj);
};

// Only get inline style elements, and the first one.
var styleSheet = toArray(document.styleSheets)
  .filter(function(ss) {
    return ss.href == null
  })[0];

var processedStyles = toArray(styleSheet.cssRules)
  // Filter out rules with pseudo classes
  .filter(function(rule) {
    return pseudoRe.test(rule.selectorText);
  })
  .map(function(rule) {
    return rule.cssText.replace(pseudoRe, function(matched) {
      // Replace `:` with `.` + escaped colon.
      return matched.replace(':', '.\\3A ');
    })
  })
  .toString();

var styleEl = document.createElement('style');
styleEl.appendChild(document.createTextNode(processedStyles));
document.getElementsByTagName('head')[0].appendChild(styleEl);

})();<commit_msg>Finish up pseudo selector script<commit_after>// Scans your stylesheet for pseudo classes and adds a class with the same name.
// Thanks to Knyle Style Sheets for the idea.

(function() {

'use strict';

// Helper function needed to deal with array-like stylesheet objects.
var toArray = function(obj) { return Array.prototype.slice.call(obj); };

// Compile regular expression
var pseudos = [ 'link', 'visited', 'hover', 'active', 'focus', 'target',
                'enabled', 'disabled', 'checked' ];
var pseudoRe = new RegExp(':((' + pseudos.join(')|(') + '))', 'gi');

// Only get inline style elements, and only the first one
var styleSheet = toArray(document.styleSheets)
  .filter(function(ss) {
    return ss.href == null
  })[0];
var processedStyles = toArray(styleSheet.cssRules)
  .filter(function(rule) {
    // Keep only rules with pseudo classes
    return rule.selectorText.match(pseudoRe);
  })
  .map(function(rule) {
    // Replace : with . and encoded :
    return rule.cssText.replace(pseudoRe, '.\\3A $1');
  })
  .reduce(function(prev, cur) {
    return prev + cur;
  });

// Add the styles to the document
var styleEl = document.createElement('style');
styleEl.appendChild(document.createTextNode(processedStyles));
document.getElementsByTagName('head')[0].appendChild(styleEl);

})();
{'fraction_non_alphanumeric': 0.15042735042735042, 'fraction_numerical': 0.0029914529914529917, 'mean_word_length': 4.089130434782609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3901810', 'n_tokens_mistral': 717, 'n_tokens_neox': 711, 'n_words': 197}