// ==UserScript==
// @name MyDealz Enhancer
// @namespace mydealz_enhancer
// @description Verbessert Funktionen von MyDealz, oder stellt sie wieder her
// @author BAERnado
// @include http://www.mydealz.de/*
// @version 0.51
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_log
// ==/UserScript==
function ModifyPage() {
var defaultSettings = {maxQuoteLevel: 1, hideAds: {topBar: true, gsWidget: true, nlSection: true, app: true}, moveButtons: {custom: true, gesuche: false, diverses: false, kleinanzeigen: false}, fromTo: {deals: 'deals-new', gutscheine: 'gutscheine-new', freebies: 'freebies-new', gesuche: 'gesuche', diverses: 'diverses', kleinanzeigen: 'kleinanzeigen', bugreports: 'bugreports'}};
var settings = {};
var timer = {};
var userName;
$.fn.hasAttr = function(name) {
return this.attr(name) !== undefined;
};
$.fn.extend({
insertAtCaret: function(myValue) {
var elem = this[0];
if (document.selection) {
elem.focus();
sel = document.selection.createRange();
sel.text = myValue;
elem.focus();
} else if (elem.selectionStart || elem.selectionStart == '0') {
var startPos = elem.selectionStart;
var endPos = elem.selectionEnd;
var scrollTop = elem.scrollTop;
elem.value = elem.value.substring(0, startPos)+myValue+elem.value.substring(endPos,elem.value.length);
elem.focus();
elem.selectionStart = startPos + myValue.length;
elem.selectionEnd = startPos + myValue.length;
elem.scrollTop = scrollTop;
} else {
elem.value += myValue;
elem.focus();
}
}
});
function printUTCDate(_date) {
return ('0'+_date.getUTCHours().toString()).replace(/^0*([0-9]{2})$/, '$1') + ':' + ('0'+_date.getUTCMinutes().toString()).replace(/^0*([0-9]{2})$/, '$1') + ':' + ('0'+_date.getUTCSeconds().toString()).replace(/^0*([0-9]{2})$/, '$1');
}
function printDate(_date) {
return ('0'+_date.getHours().toString()).replace(/^0*([0-9]{2})$/, '$1') + ':' + ('0'+_date.getMinutes().toString()).replace(/^0*([0-9]{2})$/, '$1') + ':' + ('0'+_date.getSeconds().toString()).replace(/^0*([0-9]{2})$/, '$1');
}
function timeTick() {
var _allTimes = document.getElementsByClassName('bf-carousel-date');
var _remain;
var _until;
var _diffDate;
var _toDate;
var _now = new Date();
for(var _i = 0; _i < _allTimes.length; _i++) {
_until = _allTimes[_i];
_remain = _allTimes[_i].parentNode.getElementsByClassName('bf-carousel-date-remain')[0];
_toDate = new Date();
_toDate.setTime(parseInt(_until.innerHTML, 10)*1000);
_diffDate = new Date();
_diffDate.setTime(_toDate.getTime() - _now.getTime());
_remain.innerHTML = printUTCDate(_diffDate); // + ' (' + printDate(_toDate) + ')';
}
}
function addTimes() {
var _allTimes = document.getElementsByClassName('bf-carousel-date');
var _newSpan;
for(var _i = 0; _i < _allTimes.length; _i++) {
_allTimes[_i].style.display = 'none';
_newSpan = document.createElement('span');
_newSpan.setAttribute('class', 'bf-carousel-date-remain');
_allTimes[_i].parentNode.insertBefore(_newSpan, null);
}
timeTick();
window.setInterval(timeTick, 1000);
}
function fixPositions() {
var _allElems = document.getElementsByTagName('article');
for(var _i = 0;_i < _allElems.length; _i++) {
_allElems[_i].setAttribute('style', 'position: absolute; width: 1200px; left: 0px; top: ' + _i*404 + 'px');
}
window.setTimeout("document.getElementsByTagName('article')[0].parentNode.setAttribute('style', 'height: " + _allElems.length * 404 + "px;');", 20);
}
function changeLinks() {
var _allLinks = $('a.navTrigger1, .navTrigger1-row-items .menu:last .menu-list .navMenu1-item');
var _fromTo = settings.fromTo;
var _loc;
$(_allLinks).each(function (_lInd, _lVal) {
var _link = $(_lVal);
if(_link.hasAttr('href')) {
_loc = _link.attr('href').replace(/^https?:\/\/www\.mydealz\.de(\/(hot|discussed|new)?)?$/, '/').replace(/^https?:\/\/www\.mydealz\.de\/([a-zA-Z-]+)?$/, '$1').replace(/-?(new|discussed)?$/,'');
if(_loc in _fromTo) {
_link.attr('href', _link.attr('href').replace(/^(https?:\/\/www\.mydealz\.de).*$/, '$1' + '/' + _fromTo[_loc]));
}
}
});
}
function remodelNavBar() {
// Besten Dank an lolnickname für die Vorlage
var _subMenu = $('header strong[data-handler="menu"]');
_subMenu.find('span[class!="navTrigger-arrow"]').remove();
_subMenu = _subMenu.parent().parent();
var _buttonIndex = 5;
var _button;
var _moreRemoveHighlight = false;
for(_bInd in settings.moveButtons) {
if(settings.moveButtons[_bInd]) {
_button = $('.navTrigger1-row-items.tGrid-cell.tGrid.hide--upTo-medium a[href*="' + _bInd + '"]');
if(_button.filter('.navMenu1-item--selected').length) {
_moreRemoveHighlight = true;
}
_button.filter('.navMenu1-item--selected').addClass('navTrigger1 navTrigger1--selected');
_subMenu.before(_button.removeClass('navMenu1-item navMenu1-item--selected').addClass('navTrigger1').parent().removeClass('navMenu1-item hide--downThrough-').addClass('tGrid-cell hide--upTo-menu' + _buttonIndex++));
}
}
if(_moreRemoveHighlight) {
$('header strong[data-handler="menu"]').removeClass('navTrigger1--selected');
}
}
function addCyberDealz() {
var _newMenu = $('<li>').addClass('hide--downThrough-').append($('<a>').addClass('navMenu1-item').attr('href','http://www.mydealz.de/cyber-monday/cyberdeals').html('Cyber-Deals')).appendTo($('.navMenu--width-l').eq(0));
}
function removeAds() {
var _ads = {topBar: '.topBar', gsWidget: '#gs-widget', nlSection: '.inline-newsletter, .newsletter', app: '[alt="app banner for ios android and window phone"]'};
for(_aInd in _ads) {
if(_aInd in settings.hideAds && settings.hideAds[_aInd]) {
if($(_ads[_aInd]) != null) {
$(_ads[_aInd]).remove();
}
}
}
}
function addFuncLinks() {
var _thread = $('div.thread, li.thread');
if(_thread.length) {
var _list = _thread.find('footer ul');
var _author = $.trim($(".thread-author").eq(0).text());
var _topic = $.trim($(".thread-title h1").eq(0).text());
var _pnLink = $('<li>').addClass('hList-item').append($('<a>').addClass('link').addClass('ico').attr('id', '__pnLink__').html('PN').attr('data-modal', '{"endpoint":"http:\\/\\/www.mydealz.de\\/profile\\/' + userName + '\\/messages\\/modal-window?to=' + encodeURIComponent(_author) + '"}').attr('data-handler', 'modal').attr('href', 'http://hukd.mydealz.de/profile/' + userName + '/messages/compose-mail?to=' + encodeURIComponent(_author)));
addGlobalStyle('#__pnLink__::before { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB/SURBVChTY/gPBm8+/Vh95N6kTVeACMgAciHiIOkbjz9oZ61FQ0BBkPTnb7+AnP2XniHLQbhAKYYTN14iCyEzgFIMQJsgHIgEsjFAKRRpNLTt9CMGZOVoCOg6hvsvPqGJwhHUY0C/okkAEVAQKg0Bz95+vXDvLdC1QAZU6P9/AKPpvjdJZe34AAAAAElFTkSuQmCC); background-size: 10px 10px; background-position: 3px 3px;}');
_list.append(_pnLink);
var _reportLink = _thread.find('.ico--type-megaphone-blue').parent();
_newLink = $('<li>').addClass('hList-item').html('<button class="link ico ico--type-spam-blue ico--pos-l" data-handler="replace" type="button">Spam</button>').find('button').attr('data-replace', '["/vote?v=spam&t=' + _thread.attr('id') + '", "div"]').parent();
_reportLink.before(_newLink);
_newLink = $('<li>').addClass('hList-item').html('<button class="link ico ico--type-time-blue ico--pos-l" data-handler="replace" type="button">Abgelaufen</button>').find('button').attr('data-replace', '["/vote?v=expired&t=' + _thread.attr('id') + '", "div"]').parent();
_reportLink.before(_newLink);
_reportLink.remove();
}
}
function insertDirectLink() {
// Direktlink by Nico
// onClick entfernt
$(".comments-list > li").each(function(_index) {
var _directLink = document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?page=' + $(".form--narrow input[name=cur_page]").val() +'#' + $(this).prop('id');
$(this).find(".hList:first").append("<li class=\"comment-option hList-item\"> <a href=" + _directLink +"><button class=\"link ico ico--type-arrow-blue ico--pos-l\">Direktlink</button><a/></li>");
});
}
function filterPath() {
_path = document.location.pathname.replace(/^\/(new|hot|discussed)$/, '/').replace(/^\/([^\/]+).*$/, '$1').replace(/(-?(new|discussed))?$/, '');
if(_path != '/' && !(_path in settings.fromTo)) {
return false;
}
return _path;
}
function grabQuote() {
var _quoteLink = $(this);
var _params = JSON.parse(_quoteLink.attr('data-comment-quote'));
$.ajax({
method: 'POST',
url: 'http://www.mydealz.de/comment?raw=1',
contentType: 'application/x-www-form-urlencoded',
accept: 'application/json, text/javascript, */*',
data: 'comment_id=' + _params.commentId + '&thread_id=' + _params.threadId,
dataType: 'json'
}).done(function (_rdata) {
if(typeof _rdata == 'object' && 'data' in _rdata && typeof _rdata.data == 'object' && 'comment_id' in _rdata.data) {
var _comment = '[quote=' + _params.username + ']' + _rdata.data.content + '[/quote]';
// vom HUKD Toolkit (Danke an lolnickname)
/* Zeilenwechsel entfernen */
_comment = _comment.replace(/(\r\n|\n|\r)/gm," ");
/* mehrfache Leerzeichen */
_comment = _comment.replace(/\s+/g," ");
/* einzelne Leerzeichen nach BBCode */
_comment = _comment.replace(/quote(=([a-zA-Z0-9]+)?)?\]\s/g,"quote$1]");
/* einzelne Leerzeichen vor BBCode */
_comment = _comment.replace(/\s\[(\/)?quote/g,"[$1quote");
/* Leerzeichen an Anfang und Ende des Strings */
_comment = $.trim(_comment);
_comment = maxQuotes(_comment);
$('#commentForm-content').insertAtCaret(_comment);
}
});
}
function modifyQuotes() {
var _quoteLinks = $('.ico--type-quote-blue');
if(_quoteLinks.length) {
_quoteLinks.each(function (_qlInd, _qlVal) {
var _quoteLink = $(_qlVal);
_quoteLink.removeAttr('data-track').removeAttr('data-handler');
_quoteLink.click(grabQuote);
});
}
}
function maxQuotes(quoteContent) {
// vom HUKD Toolkit (Danke lolnickname)
var quoteStartPattern = /\[quote=([0-9a-zA-Z_]+)?\]/g
var quoteEndPattern = /\[\/quote\]/g
var quoteStarts = quoteContent.match(quoteStartPattern);
var quoteEnds = quoteContent.match(quoteEndPattern);
var quoteStartCount = 0;
var quoteEndCount = 0;
if (quoteStarts && quoteEnds) {
quoteStartCount = quoteStarts.length;
quoteEndCount = quoteEnds.length;
}
if (quoteStartCount != quoteEndCount) {
alert("BBCodes fuer Zitate nicht eindeutig.");
return quoteContent;
}
/* maximale Ebenen */
/* mit 0 beginnend */
var maxQuoteLevel = settings.maxQuoteLevel;
if (quoteStartCount <= maxQuoteLevel) {
return quoteContent;
}
var startPos = new Array();
var endPos = new Array();
for (var i = 0; i < quoteStartCount; i++) {
startPos[i] = quoteContent.indexOf(quoteStarts[i], startPos[i-1] + 1);
endPos[i] = quoteContent.indexOf(quoteEnds[i], endPos[i-1] + 1);
}
var multiQuote = false;
for (var i = 0; i < quoteStartCount; i++) {
for (var j = 0; j < quoteStartCount; j++) {
if (startPos[i] >= endPos[j]) {
// not supported yet
multiQuote = true;
break;
}
}
if (multiQuote) {
break;
};
}
if (multiQuote) {
return quoteContent;
} else {
var reducedQuote = '';
var levelDiff = Math.abs(maxQuoteLevel - quoteStartCount);
contentToDiscard = quoteContent.substring(startPos[maxQuoteLevel], endPos[levelDiff - 1] + quoteEnds[levelDiff - 1].length);
reducedQuote += quoteContent.replace(contentToDiscard, '');
return reducedQuote;
}
}
function addMenuSwitcher(_path) {
addGlobalStyle('.enhancer-link-menuswitch { color: #ff0000 !important; }');
_path = filterPath(_path);
if(!_path) {
return;
}
var _menu = $('.navTrigger2-row .fGrid-last .menu:first');
if(_menu.length) {
_menu.on('mouseenter', initMenuSwitch);
_menu.on('mouseleave', stopMenuSwitch);
}
}
function initMenuSwitch() {
timer.menuSwitch = window.setTimeout(menuSwitch, 3000);
}
function menuSwitch() {
var _menu = $('.navTrigger2-row .fGrid-last .menu:first');
_menu.find('li a.nav2Morph-link').addClass('enhancer-link-menuswitch').on('click', savePageChoice);
_menu.find('li a.nav2Morph-link--selected').addClass('enhancer-link-menuswitch--selected');
}
function savePageChoice() {
var _elem = $(this);
_path = filterPath(_path);
if(!_path) {
return;
}
settings.fromTo[_path] = _elem.attr('href').replace(document.location.origin + '/', '');
saveSettings();
}
function stopMenuSwitch() {
if('menuSwitch' in timer) {
try {
window.clearTimeout(timer.menuSwitch);
} finally {
delete timer.menuSwitch;
}
}
var _menu = $('.navTrigger2-row .fGrid-last .menu:first');
_menu.find('.enhancer-link-menuswitch').removeClass('enhancer-link-menuswitch').removeClass('enhancer-link-menuswitch--selected').off('click', savePageChoice);
}
function addImageZoom() {
// Besten Dank an vielleichtmann1 für die Idee
// Bilder-Vergroesserungs-Button einfuegen
var _imgs = $('.imageFrame-image');
if(_imgs.length) {
_imgs.each(function (_iInd, _iVal) {
var _img = $(_iVal);
var _link = $('<a>').attr('href', _img.attr('src').replace("threads/", "threads/high-res/")).attr('target', '_blank');
_link.appendTo(_img.parent()).append(_img);
_link.click(zoomImage);
});
}
}
function zoomImage(_evt) {
_evt.preventDefault();
_evt.stopPropagation();
var _link = $(this);
var _container = $('<div>').attr('style', 'position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 99; background-color: rgba(68,68,68,0.5); white-space: nowrap; text-align: center; margin: 0;').appendTo($(document.body)).append($('<span>').attr('style', 'display: inline-block; height: 100%; vertical-align: middle;')).append($('<img>').attr('src', _link.attr('href')).attr('style', 'vertical-align: middle; max-height: ' + ($(window).height() - 2) + 'px; max-width: ' + ($(window).width() - 2) + 'px; border-radius: 5px; border: 1px solid #ffffff;'));
_container.click(function () { $(this).remove();});
}
function addDealLinks() {
// Danke an vielleichtmann1 für die Idee
var _thread = $('div.thread div.thread-body div.section-sub').eq(0);
if(_thread.length) {
_thread.html(_thread.html().replace(/([^\";]https?:\/\/[^ ]+?)(\n|\<br\>|\s)/g, '<a href="$1" target="_blank">$1</a>$2'));
}
}
function retrieveUserName() {
try {
userName = $('.userBar-userCenter-menu .avatar-frame').parent().html().replace(/(\r|\n)/g, '').replace(/^.*\\\/profile\\\/([^\\\<\>]+)\\\/ajax.*$/, '$1');
} catch (e) {
alert('Bitte einloggen.');
window.location.href = 'https://www.mydealz.de/login';
}
}
function addGlobalStyle(_css) {
var _head, _style;
_head = document.getElementsByTagName('head')[0];
if (!_head) { return; }
_style = document.createElement('style');
_style.type = 'text/css';
_style.innerHTML = _css;
_head.appendChild(_style);
}
function loadSettings() {
var _verbose = false;
var _lSettings = JSON.parse(GM_getValue('settings', '{}'));
var _sprop;
// sinnvolleren, rekursiven Parser schreiben
for (var _prop in defaultSettings) {
if(_prop in _lSettings) {
settings[_prop] = _lSettings[_prop];
} else {
settings[_prop] = defaultSettings[_prop];
}
if(_verbose) {
GM_log(_prop + ': ' + settings[_prop]);
}
for(_sprop in defaultSettings[_prop]) {
if(typeof _lSettings[_prop] == 'object' && _sprop in _lSettings[_prop]) {
settings[_prop][_sprop] = _lSettings[_prop][_sprop];
} else {
settings[_prop][_sprop] = defaultSettings[_prop][_sprop];
}
if(_verbose) {
GM_log(_prop + '.' + _sprop + ': ' + settings[_prop][_sprop]);
}
}
}
}
function addSetupLink() {
var _newMenu = $('<li>').addClass('hide--downThrough-').attr('id', 'mydealz-enhancer-setup--link').append($('<a>').addClass('navMenu1-item').attr('href','#mydealz-enhancer').html('MyDealz-Enhancer')).appendTo($('.navMenu--width-l').eq(0));
_newMenu.find('a').click(showSetup);
}
function saveSettings() {
GM_setValue('settings', JSON.stringify(settings));
}
function showSetup() {
document.title = 'MyDealz-Enhancer Einstellungen';
$('strong[data-handler="menu"]').parent().parent().removeClass('menu--active');
$('.navTrigger1--selected, .navMenu1-item--selected').removeClass('navTrigger1--selected navMenu1-item--selected');
$('#mydealz-enhancer-setup--link').addClass('navMenu1-item--selected');
$('.navTrigger2-row').remove();
$('#main').parent().find('aside').remove();
$('.page-canvas > section').eq(0).remove();
$('#main').html('').attr('class', 'content-main content-background').html('<ul class="breadcrumb section--padded--tight"><li class="breadcrumb-item size--all-xSmall size--xxSmall-small" itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" itemprop="child"><a class="breadcrumb-link link" href="/" itemprop="url">Home</a><ul class="breadcrumb-list "><li class="breadcrumb-item size--all-xSmall size--xxSmall-small" itemtype="http://data-vocabulary.org/Breadcrumb" itemscope="itemscope" itemprop="child"><span class="breadcrumb-current">Bearbeite Deine MyDealz-Enhancer Einstellungen</span></li></ul></li></ul><form class="form"><div class="section section--padded"><h1 class="section-title">Bearbeite Deine MyDealz-Enhancer Einstellungen</h1></div></form>');
var _sections = $('#main .section--padded');
var _form = $('#main form.form');
_form.submit(submitSettings);
var _section = $('<section>').addClass('section-sub').html('<h2 class="section-subTitle">Info und Diskussionsthread</h2><p>Informationen und Verbesserungsvorschläge im <a href="http://www.mydealz.de/diverses/mydealz-enhancer-userscript-573012" class="link">MyDealz-Enhancer-Thread</a>.');
_section.appendTo(_sections);
_section = $('<section>').addClass('section-sub').html('<h2 class="section-subTitle">Werbung ausblenden</h2><ul class="form-list"><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="adForm-hideAds_topBar" type="checkbox" name="hideAds_topBar"> Top-Bar (Gutscheinsammler, Urlaubspiraten, …)</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="adForm-hideAds_nlSection" type="checkbox" name="hideAds_nlSection"> Newsletter</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="adForm-hideAds_gsWidget" type="checkbox" name="hideAds_gsWidget"> Gutschein-Widget</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="adForm-hideAds_app" type="checkbox" name="hideAds_app"> MyDealz-App</label></div></li></ul>');
_section.appendTo(_sections);
for(var _sInd in settings.hideAds) {
if(settings.hideAds[_sInd]) {
_section.find('#adForm-hideAds_' + _sInd).prop('checked', 'checked').attr('checked', 'checked');
} else {
_section.find('#adForm-hideAds_' + _sInd).prop('checked', false).removeAttr('checked');
}
}
_section = $('<section>').addClass('section-sub').html('<h2 class="section-subTitle">Buttons im Hauptmenu</h2><ul class="form-list"><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="buttonForm-moveButtons_custom" type="checkbox" name="moveButtons_custom"> MyTab</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="buttonForm-moveButtons_gesuche" type="checkbox" name="moveButtons_gesuche"> Gesuche</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="buttonForm-moveButtons_diverses" type="checkbox" name="moveButtons_diverses"> Diverses</label></div></li><li class="form-list-row"><span class="form-list-label"></span><div class="form-list-content"><label class="form-text"><input id="buttonForm-moveButtons_kleinanzeigen" type="checkbox" name="moveButtons_kleinanzeigen"> Kleinanzeigen</label></div></li></ul>');
_section.appendTo(_sections);
for(var _sInd in settings.moveButtons) {
if(settings.moveButtons[_sInd]) {
_section.find('#buttonForm-moveButtons_' + _sInd).prop('checked', 'checked').attr('checked', 'checked');
} else {
_section.find('#buttonForm-moveButtons_' + _sInd).prop('checked', false).removeAttr('checked');
}
}
_section = $('<section>').addClass('section-sub').html('<h2 class="section-subTitle">Kommentieren</h2><ul class="form-list"><li class="form-list-row"><label class="form-list-label" for="commentForm-maxQuoteLevel"> Zitattiefe </label><div class="form-list-content"><input id="commentForm-maxQuoteLevel" class="input" type="number" min="1" required="" name="maxQuoteLevel"></div></li></ul>');
_section.appendTo(_sections);
_section.find('#commentForm-maxQuoteLevel').val(settings.maxQuoteLevel).attr('value', settings.maxQuoteLevel);
_sections.find('section.section-sub:last ul').append($('<li>').addClass('form-list-row').html('<span class="form-list-label"></span><div class="form-list-content"><input class="button button--type-primary" type="submit" name="save_privacy_options" value="Speichern"><input class="link form-cancel" type="reset" value="Zurücksetzen"></div>'));
}
function createMessageWindow(_text, _type) {
var _messageList = $('#globalMsg .globalMsg-list');
$('<li>').addClass('globalMsg-item globalMsg-item--type-success message message--type-success').html('<li class="globalMsg-item globalMsg-item--type-' + _type + ' message message--type-' + _type + '"><div class="message-inner mGrid"><span class="globalMsg-icon globalMsg-icon--type-' + _type + ' mGrid-media centerChild2 ico ico--middle size--all-large"></span><button data-handler="globalMsg-close" class="globalMsg-close fGrid-right space--left-4 ico ico--type-close-' + (_type == 'error' ? 'red' : 'green' )+ '"></button><div class="mGrid-content"><div class="globalMsg-title">' + _text + '</div></div></div></li>').appendTo(_messageList);
window.setTimeout(function () {
try {
_messageList.find('li').remove();
} catch(e) {
}
}, 8000);
}
function submitSettings(_evt) {
_evt.preventDefault();
_evt.stopPropagation();
var _allOK = true;
for(var _sInd in settings.hideAds) {
try {
settings.hideAds[_sInd] = $('#adForm-hideAds_' + _sInd).prop('checked');
} catch(e) {
alert(e);
_allOK = false;
}
}
var _allOK = true;
for(var _sInd in settings.moveButtons) {
try {
settings.moveButtons[_sInd] = $('#buttonForm-moveButtons_' + _sInd).prop('checked');
} catch(e) {
_allOK = false;
}
}
try {
settings.maxQuoteLevel = parseInt($('#commentForm-maxQuoteLevel').val(), 10);
} catch (e) {
_allOK = false;
}
if(_allOK) {
saveSettings();
createMessageWindow('Deine Einstellungen wurden gespeichert.', 'success');
} else {
createMessageWindow('Ein Fehler trat beim Speichern auf.', 'error');
}
}
function init() {
var _noError = true;
try {
var _path = document.location.pathname.replace(/\/([^\?]+).*$/, '$1');
if(/^(visit|image)/.test(_path) || /^JavaScript Shell/.test(document.title)) {
return;
}
retrieveUserName();
loadSettings();
var _path = filterPath();
addMenuSwitcher(_path);
remodelNavBar();
removeAds();
addCyberDealz();
addSetupLink();
changeLinks();
if(document.location.hash == '#mydealz-enhancer') {
showSetup();
}
switch(document.location.pathname.replace(/\/([^\?]+).*$/, '$1')) {
case 'cyber-monday/cyberdeals':
addTimes();
}
addImageZoom();
addFuncLinks();
modifyQuotes();
insertDirectLink();
addDealLinks();
} catch (e) {
alert(e);
_noError = false;
}
// Danke an lolnickname für die Idee
$('.userBar-link .avatar-image').css( 'border', '1px dotted ' + (_noError ? '#00ff00' : '#aa0000' ) );
}
init();
}
// Erst ladne, wenn DOM fertig ist
if(document.readyState == 'complete') {
ModifyPage();
} else {
window.addEventListener('load', ModifyPage, false);
}