<commit_before>
var getPageSync = function(link) {
  if (link.length === 0) {
    return "";
  }

  var request = new XMLHttpRequest();

  request.open('GET', link, false);
  request.send();

  return request.responseText;
}

var getDirectLink = function(page) {
  if (page.length === 0) {
    return "";
  }

  var el = document.createElement('div');
  el.innerHTML = page;

  var link = el.querySelector('a.link[href*="-sfast.html"]')
                .getAttribute('href');

  if (link !== undefined) {
    return 'http://superweb.rol.ro' +
            getPageSync('http://990.ro/' + link)
            .match(/\/video\/.*\.html/g)
            .toString()
            .replace('/video/', '/video/3/');
  }

  return "";
}

var addDirectLinkButton = function(link, text, upperElement, id) {
  var el = document.createElement('a');

  el.id = id;
  el.setAttribute('href', link);
  el.classList.add('button-9')
  el.innerHTML = text;

  if (link === '') {
    el.style.visibility='hidden';
  }

  document.querySelector(upperElement)
          .insertAdjacentHTML('afterend', el.outerHTML);
}

var addSuperwebNav = function(buttonId, buttonName) {
  chrome.storage.sync.get('current', function(result) {
    var el = document.createElement('div');
    el.innerHTML = getPageSync(result.current);

    var link990 = Array.prototype.slice
                .call(el.querySelectorAll('a.episode_nextprev'))
                .filter(function(e) {
                  if (e['innerText'] === buttonName) {
                    return e;
                  }
                })
                .map(function(e) {
                  return 'http://990.ro/' + e['href']
                      .slice(e['href'].indexOf('/video/') + 8);
                });

    var directLink = getDirectLink(getPageSync(link990));

    addDirectLinkButton(directLink, buttonName, '.hline', buttonId);

    document.getElementById(buttonId).onclick = function() {
      chrome.storage.sync.set({ 'current': link990 });

      return true;
    };
  });
}

var handleSuperweb = function() {
  if (!window.location.href.includes('/video/')) {
    return;
  }

  if (!document.getElementById('html5_b') && window.location.href.includes('/3/')) {
    window.location.href = window.location.href.replace('/3/', '/1/');
  }

  var el = document.querySelector('.all');
  el.parentNode.removeChild(el);

  addSuperwebNav('prevButton', 'Episodul anterior');
  addSuperwebNav('nextButton', 'Episodul urmator');
}

var handle990 = function () {
  if (!(window.location.href.includes("seriale2-") ||
        window.location.href.includes("filme-"))) {
    return;
  }

  addDirectLinkButton(getDirectLink(getPageSync(window.location.href)),
                      'Link direct', '#content div', 'directButton');

  document.getElementById('directButton').onclick = function() {
    chrome.storage.sync.set({ 'current': window.location.href });

    return true;
  };
}

handle990();
handleSuperweb();
<commit_msg>Update 990Direct.js<commit_after>
var getPageSync = function(link) {
  if (link.length === 0) {
    return "";
  }

  var request = new XMLHttpRequest();

  request.open('GET', link, false);
  request.send();

  return request.responseText;
}

var getDirectLink = function(page) {
  if (page.length === 0) {
    return "";
  }

  var el = document.createElement('div');
  el.innerHTML = page;

  var link = el.querySelector('a.link[href*="-sfast.html"]')
                .getAttribute('href');

  if (link !== undefined) {
    return 'http://superweb.rol.ro' +
            getPageSync('http://990.ro/' + link)
            .match(/\/video\/.*\.html/g)
            .toString()
            .replace('/video/', '/video/3/');
  }

  return "";
}

var addDirectLinkButton = function(link, text, upperElement, id) {
  var el = document.createElement('a');

  el.id = id;
  el.setAttribute('href', link);
  el.setAttribute('style',' display: inline-block;  text-decoration: none;  background-color: #4CAF50;  vertical-align: text-center;  box-shadow: rgba(0,0,0,0.2) 0 1px 0 0;  border-radius: 5px;  color: #fff;  border: none;  font-family: "Helvetica Neue", Arial, sans-serif;  font-size: 16px;  font-weight: 700;  height: 32px;  padding: 4px 16px;  text-shadow: #1B5E20 0 1px 0;  margin: 10px; ');  
  //el.classList.add('button-9')
  el.innerHTML = text;

  if (link === '') {
    el.style.visibility='hidden';
  }

  document.querySelector(upperElement)
          .insertAdjacentHTML('afterend', el.outerHTML);
}

var addSuperwebNav = function(buttonId, buttonName) {
  chrome.storage.sync.get('current', function(result) {
    var el = document.createElement('div');
    el.innerHTML = getPageSync(result.current);

    var link990 = Array.prototype.slice
                .call(el.querySelectorAll('a.episode_nextprev'))
                .filter(function(e) {
                  if (e['innerText'] === buttonName) {
                    return e;
                  }
                })
                .map(function(e) {
                  return 'http://990.ro/' + e['href']
                      .slice(e['href'].indexOf('/video/') + 8);
                });

    var directLink = getDirectLink(getPageSync(link990));

    addDirectLinkButton(directLink, buttonName, '.hline', buttonId);

    document.getElementById(buttonId).onclick = function() {
      chrome.storage.sync.set({ 'current': link990 });

      return true;
    };
  });
}

var handleSuperweb = function() {
  if (!window.location.href.includes('/video/')) {
    return;
  }

  if (!document.getElementById('html5_b') && window.location.href.includes('/3/')) {
    window.location.href = window.location.href.replace('/3/', '/1/');
  }

  var el = document.querySelector('.all');
  el.parentNode.removeChild(el);

  addSuperwebNav('prevButton', 'Episodul anterior');
  addSuperwebNav('nextButton', 'Episodul urmator');
}

function makeid()
{
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    for( var i=0; i < 5; i++ )
        text += possible.charAt(Math.floor(Math.random() * possible.length));

    return text;
}

var handle990 = function () {
  if (!(window.location.href.includes("seriale2-") ||
        window.location.href.includes("filme-"))) {
    return;
  }

  id = makeid();
  
  addDirectLinkButton(getDirectLink(getPageSync(window.location.href)),
                      'Link direct', '#content div', id);

  document.getElementById(id).onclick = function() {
    chrome.storage.sync.set({ 'current': window.location.href });

    return true;
  };
}

handle990();
handleSuperweb();

{'fraction_non_alphanumeric': 0.17018690168667375, 'fraction_numerical': 0.016562832396292356, 'mean_word_length': 2.7525655644241733, 'pattern_counts': {'":': 0, '<': 4, '<?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': '1912456', 'n_tokens_mistral': 2187, 'n_tokens_neox': 2050, 'n_words': 369}