skype_anonymous / Shush.se latest episode

// ==UserScript==
// @name       Shush.se latest episode
// @version    2.0
// @description  Adds the "latest episode" button.
// @match      http://www.shush.se/*
// @copyright  2014+, HereForLost
// @grant none
// ==/UserScript==
var pageurl = document.URL;
if (pageurl.indexOf('?shows') >= 1)
{
  var id_serie = decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent('serie').replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
  var episodio = decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent('id').replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
  if ( id_serie  && episodio)
  {
    $('div.menu').append('<div style="text-align:center;font-size:24px;"><br /><a style="margin-right:200px; margin-top:10px;" href="http://www.shush.se/index.php?id=' + episodio + '&show=' + id_serie + '">Latest episode</a>)');
  }
} 
else if (pageurl.indexOf('?id') >= 1 && pageurl.indexOf('&movie') <= 1)
{
  var d = new Date();
  var id = document.URL.slice(pageurl.indexOf('=') + 1, pageurl.indexOf('=') + 3);
  id = parseInt(id);
  id = id + 1;
  var serie = document.URL.slice(pageurl.indexOf('show=') + 5, pageurl.length);
  d.setTime((d.getTime() + (7 * 24 * 60 * 60 * 1000))); //sets the timer variable to a week.
  document.cookie = 'serie=' + serie + '; expires=' + d.toGMTString() + '; path=/';
  document.cookie = 'id=' + id + '; expires=' + d.toGMTString() + '; path=/';
}