Mydealz Script

Versteckt abgelaufene Dealz, verbreitert die Seitenansicht, entfernt den Newsletterhinweis und entfernt einige Referrerlinks

As of 11.03.2016. See апошняя версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Mydealz Script
// @description Versteckt abgelaufene Dealz, verbreitert die Seitenansicht, entfernt den Newsletterhinweis und entfernt einige Referrerlinks
// @namespace   cuzi
// @oujs:author cuzi
// @version     1
// @license     GNUGPL
// @include     /^https?:\/\/www\.mydealz\.de\/.*/
// @exclude     /^https?:\/\/www\.mydealz\.de\/profile\/.*/
// @exclude     /^https?:\/\/www\.mydealz\.de\/search.*/
// @grant       none
// ==/UserScript==

function reviveDeal() {
  this.removeEventListener('click',reviveDeal);
  this.style.maxHeight = "";
  this.style.opacity = 1.0;
}

function restoreLinks() {
  var a = document.querySelectorAll("a[target]");
  var pattern0 = /^http:\/\/www\.mydealz\.de\/visit\?.*&d=(.+)/;
  var pattern1 = /&redir=(http.+)"/;
  var pattern2 = /"label":"(http.+)"/;

  for(let i = 0; i < a.length; i++) {
    if(pattern0.test(a[i].href)) {
      a[i].href = decodeURIComponent(pattern0.exec(a[i].href)[1]);
    } else if("track" in a[i].dataset && pattern1.test(a[i].dataset.track)) {
      a[i].href = decodeURIComponent(pattern1.exec(a[i].dataset.track)[1]);    
    } else if("track" in a[i].dataset && pattern2.test(a[i].dataset.track)) {
      a[i].href = decodeURIComponent(pattern2.exec(a[i].dataset.track)[1]);    
    } 
  }
}

(function main() {

// Widen page content
document.querySelector('.page-canvas>.page-content').style.maxWidth = '120em';

// Restore links
restoreLinks();

// Remove newsletter info
try {
  var n = document.querySelector('li.inline-newsletter');
  n.parentNode.removeChild(n); 
} catch(e) {}

// Put expired dealz to sleep
var lis = document.querySelectorAll('.thread--expired .thread-title'); 
for(let i = 0; i < lis.length; i++) {
  var li = lis[i].parentNode.parentNode.parentNode.parentNode;
  var s = li.style;
  s.maxHeight = '10em';   
  s.overflow = 'auto';
  s.opacity = 0.5;
  li.addEventListener('click',reviveDeal);
}

})();