// ==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 1.4.002 // @require http://code.jquery.com/jquery-2.1.4.min.js // @grant GM_getValue // @grant GM_setValue // @grant GM_log // @grant GM_info // @downloadURL none // ==/UserScript== function ModifyPage() { var defaultSettings = {behavior: {showGreenDots: true}, comments: {maxQuoteLevel: 1, editReason: '', signature: '', useSignature: false}, deals: {hide: ''}, userMenuDirect : {pn: false, account: false}, hideAds: {topBar: true, gsWidget: true, inside: true,nlSection: true, app: true}, moveButtons: {_: true, deals: true, gutscheine: true, freebies: true, custom: true, gesuche: false, diverses: false}, fromTo: {deals: 'deals-new', gutscheine: 'gutscheine-new', freebies: 'freebies-new', gesuche: 'gesuche', diverses: 'diverses', bugreports: 'bugreports'}, smileys: {}, oldSmileys: {use: false, show: false}}; var settings = {}; var oldSmileys = {oO: 'http://up.picr.de/24681919lc.png', ':(': 'http://up.picr.de/24681920wk.png', ':)': 'http://up.picr.de/24681921vt.png', ':p': 'http://up.picr.de/24681922sp.png', ';)': 'http://up.picr.de/24681923bn.png', '(_;)': 'http://up.picr.de/24681924zb.png', ':|': 'http://up.picr.de/24681925vj.png', ':{': 'http://up.picr.de/24682144sm.png', '8)': 'http://up.picr.de/24682161iz.png', 'X)': 'http://up.picr.de/24682170wf.png', '<3': 'http://up.picr.de/24682514fl.png'}; var timer = {}; var lastFocus = null; var save = {pn: {}}; 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; var oldLength = elem.value.length; elem.value = elem.value.substring(0, startPos)+myValue+elem.value.substring(endPos,elem.value.length); elem.focus(); elem.selectionStart = startPos + elem.value.length - oldLength; elem.selectionEnd = startPos + elem.value.length - oldLength; elem.scrollTop = scrollTop; } else { elem.value += myValue; elem.focus(); } } }); $.fn.setCursorPosition = function(pos) { var _elem = this[0]; if (_elem.setSelectionRange) { _elem.setSelectionRange(pos, pos); } else if (_elem.createTextRange) { var range = _elem.createTextRange(); range.collapse(true); if(pos < 0) { pos = $(_elem).val().length + pos; } range.moveEnd('character', pos); range.moveStart('character', pos); range.select(); } } if(!RegExp.escape){ RegExp.escape = function(s){ return String(s).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); }; } 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 _diffTime; 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(); _diffTime = _toDate.getTime() - _now.getTime(); if(_diffTime <= 0) { $(_allTimes[_i]).parent().find('.space--left-2').text(/Beginnt in/.test($(_allTimes[_i]).parent().find('.space--left-2').text('')) ? 'Begonnen' : 'Abgelaufen'); $(_remain).remove(); } else { _diffDate.setTime(_diffTime); _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 = 1; var _buttonBeforeSubIndex = 0; var _button; var _subHiddenButton; var _selected; var _moreHighlight = true; for(_bInd in settings.moveButtons) { if(_bInd == '_') { _button = $('.navTrigger1-row-items > li > a.navTrigger1[href="http://www.mydealz.de/"], .navTrigger1-row-items li.menu ul.menu-list li.hide--downThrough- a[href="http://www.mydealz.de/"]'); } else { _button = $('.navTrigger1-row-items > li > a.navTrigger1[href*="' + _bInd + '"], .navTrigger1-row-items li.menu ul.menu-list li.hide--downThrough- a[href*="' + _bInd + '"]'); } _selected = _button.hasClass('navTrigger1--selected') || _button.hasClass('navMenu1-item--selected'); if(_button.hasClass('navTrigger1') && settings.moveButtons[_bInd]) { _button.attr('class', 'navTrigger1 navTrigger1hide--upTo-menu' + _buttonIndex++); } else if (_button.hasClass('navTrigger1') && !settings.moveButtons[_bInd]) { // Verschiebe in Untermenu _subMenu.find('li.hide--downThrough- a.navMenu1-item').eq(_buttonBeforeSubIndex++).parent().before(_button.attr('class', 'navMenu1-item').parent().attr('class', 'hide--downThrough-')); } else if(_button.hasClass('navMenu1-item') && settings.moveButtons[_bInd]) { // Verschiebe ins Hauptmenu _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(_selected) { if(_button.hasClass('navTrigger1')) { _button.addClass('navTrigger1--selected'); _moreHighlight = false; } else { _button.addClass('navMenu1-item--selected'); if($('header.header .navTrigger1-row .navTrigger1-row-items a.navTrigger1[href="' + _button.attr('href') + '"]').length == 0) { _moreHighlight = true; } else { _moreHighlight = false; } } } } for(_buttonIndex = 1; _buttonIndex <= 4; _buttonIndex++) { _button = $('.navTrigger1-row-items > li.hide--upTo-menu' + _buttonIndex + ' > a.navTrigger1'); if(_button.length) { _subHiddenButton = $('.navTrigger1-row-items li.menu ul.menu-list li.hide--downThrough-menu' + _buttonIndex + ' a'); _subHiddenButton.attr('href', _button.attr('href')).html(_button.html()); } else { $('.navTrigger1-row-items li.menu ul.menu-list li.hide--downThrough-menu' + _buttonIndex).remove(); } } $('header strong[data-handler="menu"]').removeClass('navTrigger1--selected'); if(_moreHighlight) { $('header strong[data-handler="menu"]').addClass('navTrigger1--selected'); } if(settings.userMenuDirect.pn) { var _menuElem = $('ul.userBar label.userBar-button--pm').removeAttr('data-menu').removeAttr('data-handler'); _menuElem.find('input').removeAttr('data-handler').click(function() { window.location.href = document.location.protocol + '//' + document.location.hostname + '/profile/' + userName + '/messages'; }); } if(settings.userMenuDirect.account) { var _menuElem = $('ul.userBar label.userBar-button--user').removeAttr('data-menu').removeAttr('data-handler'); _menuElem.find('input').removeAttr('data-handler').click(function() { window.location.href = document.location.protocol + '//' + document.location.hostname + '/profile/' + userName; }); } var _addDeal = $('.navTrigger1-row ul.header-user>li.userbar-padding-right span.inline'); _addDeal.text(_addDeal.text().replace(/ eintragen/,'')); } function addCyberDealz() { var _newMenu = $('
  • ').addClass('hide--downThrough-').append($('').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', inside: "#side section[data-track=\"{\\\"category\\\":\\\"Banner Sidebar\\\"}\"]", 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 _threads = $('div.thread, li.thread'); if(_threads.length) { $(_threads).each(function (_tInd, _tVal) { _thread = $(_tVal); var _list = _thread.find('footer ul'); var _author = $.trim(_thread.find(".thread-author").eq(0).text()); var _topic = $.trim(_thread.find(".thread-title h1").eq(0).text()); var _pnLink = $('
  • ').addClass('hList-item').append($('').click(startWaitForPN).addClass('link').addClass('ico').addClass('ico--type-pn-blue').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('.ico--type-pn-blue::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 = $('
    ').addClass('hList-item').html('').find('button').attr('data-replace', '["/vote?v=spam&t=' + _thread.attr('id') + '", "div"]').parent(); _reportLink.before(_newLink); _newLink = $('
    ').addClass('hList-item').html('').find('button').attr('data-replace', '["/vote?v=expired&t=' + _thread.attr('id') + '", "div"]').parent(); _reportLink.before(_newLink); _reportLink.remove(); }); } } function startWaitForPN () { var _thread_id = $('div.thread, li.thread').has($(this)).attr('id'); timer.pn = window.setInterval(function () { waitForPN(_thread_id) }, 50); } function waitForPN(_thread_id) { if(!$('#' + _thread_id).find('.ico--type-pn-blue').hasClass('seal--spin')) { if('pn' in timer) { window.clearInterval(timer.pn); delete timer.pn; } $('#pm-subject').val($.trim($('#' + _thread_id + ' header.thread-head div.thread-title .inlineText').text())); saveRestorePN($.trim($('#' + _thread_id + ' header.thread-head .thread-meta a.thread-author').text()), _thread_id); } } 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("
  • "); }); } function addFeedbackButtons() { var _thread = $('div.thread'); if(_thread.length) { var _list = _thread.find('footer ul'); var _author = $.trim(_thread.find(".thread-author").eq(0).text()); } } function markPnRead() { if(settings.userMenuDirect.pn) { $.ajax({ method: 'POST', url: 'http://www.mydealz.de/activity?type=pm', contentType: 'application/x-www-form-urlencoded', accept: 'application/json, text/javascript, */*', dataType: 'json' }).done(function () { $('#activities-count-pm').remove(); }); } } 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 startWaitForSubmit() { timer.submit = window.setInterval(waitForSubmit, 50); } function waitForSubmit() { if(!$('#commentForm').eq(0).hasClass('seal--spin')) { if('submit' in timer) { window.clearInterval(timer.submit); delete timer.submit; } modifyComments(); addFeedbackButtons(); } } function startWaitForChange() { var _link = $(this); var _params = JSON.parse(_link.attr('data-replace'))[2]; timer['change_'+_params.comment_id] = window.setInterval(function() { waitForChange(_params.comment_id)}, 50); } function waitForChange(_comment_id) { if(!$('ul.comments-list #post' + _comment_id + ' div.comments-body').eq(0).hasClass('seal--spin')) { if(('change_'+_comment_id) in timer) { window.clearInterval(timer['change_'+_comment_id]); delete timer['change_'+_comment_id]; } $('ul.comments-list #post' + _comment_id + ' #commentEditForm-reason').attr('value', settings.comments.editReason).val(settings.comments.editReason); var _commentField = $('#commentEditForm-content-' + _comment_id); _commentField.val(_commentField.val().replace(/\$/m, '')); _commentField.change(customSmileys); _commentField.parent().parent().parent().parent().parent().parent().find('#commentEditForm-reason').change(customSmileys); _commentField.parent().find('div.markItUpHeader li.editor-option--type-emoticons>button').click(startWaitForSmileys); } } function startWaitForSmileys() { lastFocus = $(':focus'); var _li = $(this); try { var _form = $(_li.parent().parent().parent().parent().find('textarea.input')[0].form); var _comment_id = 'new'; if(_form.attr('id') == 'commentEditForm') { _comment_id = _form.find('input[name="comment_id"]').val(); } timer['smileys_'+_comment_id] = window.setInterval(function() { waitForSmileys(_comment_id)}, 5); } catch (e) { } } function waitForSmileys(_comment_id) { if($('#powerTip:visible>ul>li>a').length) { if(('smileys_'+_comment_id) in timer) { window.clearInterval(timer['smileys_'+_comment_id]); delete timer['smileys_'+_comment_id]; } $('#powerTip>ul>li>a').each(function(_sInd, _sVal) { if($(_sVal).attr('title') in oldSmileys) { var _li = $(_sVal).parent(); var _classes = _li.attr('class').split(/ /); $(_classes).each(function (_cInd, _cVal) { if(_cVal.match(/^editor-menu-item--type-/)) { _li.removeClass(_cVal); } }); _li.find('>a').attr('style', "background-image: url('" + oldSmileys[$(_sVal).attr('title')] + "');"); } }); // eigene Smileys var _sID = parseInt(($('#powerTip>ul>li:last').attr('class') + ' ').replace(/^.*markItUpButton5-([0-9]+) .*$/, '$1'), 10); for(_sInd in settings.smileys) { var _newElem = $('
  • ').addClass('markItUpButton markItUpButton5-' + (++_sID) + ' iGrid-item text--align-center editor-menu-item').append(''); $('#powerTip>ul').append(_newElem); _newElem.find('>a').click(addSmileyToComment); } } } function addSmileyToComment() { var _smiley = '[img]' + settings.smileys[$(this).attr('title')] + '[/img]'; if(lastFocus.prop('tagName').toLowerCase() == 'textarea') { var _selStart = lastFocus[0].selectionStart; var _newText = lastFocus.val().substr(0,_selStart) + _smiley + lastFocus.val().substr(lastFocus[0].selectionEnd); lastFocus.val(_newText); lastFocus[0].selectionEnd = lastFocus[0].selectionStart = _selStart + _smiley.length; } } function startWaitForCommentMenu(_commentField) { timer['commentmenu'] = window.setInterval(function() { waitForCommentMenu(_commentField)}, 50); } function waitForCommentMenu(_commentField) { var _li = _commentField.parent().find('div.markItUpHeader li.editor-option--type-emoticons'); if(_li.length) { window.clearInterval(timer['commentmenu']); delete(timer['commentmenu']); _li.find('>button').click(startWaitForSmileys); } } function customSmileys() { var _commentField = $(this); if(settings.oldSmileys.use) { for(_sInd in oldSmileys) { _commentField.val(_commentField.val().replace(new RegExp(RegExp.escape(_sInd), 'g'), '[img]'+oldSmileys[_sInd]+'[/img]')); } } for(_sInd in settings.smileys) { _commentField.val(_commentField.val().replace(new RegExp(RegExp.escape(_sInd), 'g'), '[img]'+settings.smileys[_sInd]+'[/img]')); } } function modifyComments() { var _changeLinks = $('ul.comments-list .ico--type-edit-blue').off('click', startWaitForChange).on('click', startWaitForChange); $('#commentForm').submit(startWaitForSubmit); _commentField = $('#commentForm-content'); if(settings.comments.useSignature) { if(_commentField.length && settings.comments.signature.length && _commentField.val().indexOf(settings.comments.signature) == -1) { _commentField.val(_commentField.val() + "\n" + settings.comments.signature); _commentField.setCursorPosition(0); } } _commentField.change(customSmileys); _commentField.blur(customSmileys); startWaitForCommentMenu(_commentField); 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); }); } var _userAvatars = $('img.avatar-image--comment:not([data-popover*="/' + userName + '?"])'); if(_userAvatars.length) { _userAvatars.off('click', startWaitForUserCommentMenu).on('click', startWaitForUserCommentMenu); } } function startWaitForUserCommentMenu() { var _link = $(this); var _commentUser = _link.attr('data-popover').replace(/^.*profile\\\/([^\?]+)\?.*$/, '$1'); timer['userCommentMenu_'+_commentUser] = window.setInterval(function() { waitForUserCommentMenu(_commentUser)}, 50); } function waitForUserCommentMenu(_commentUser) { if($('#powerTip > div').hasClass('profile')) { if('userCommentMenu_' + _commentUser in timer) { window.clearInterval(timer['userCommentMenu_' + _commentUser]); delete timer['userCommentMenu_' + _commentUser]; } // attach Events on PN-Button $('#powerTip > div.profile ul.profile-column a.button').has('span.ico--type-mail-white').on('click', startWaitForCommentPN); } } function startWaitForCommentPN() { var _link = $(this); var _pnUser = _link.attr('href').replace(/^.*\?to=(.*)$/, '$1'); timer['pnWindow_'+_pnUser] = window.setInterval(function() { waitForCommentPN(_pnUser)}, 50); } function waitForCommentPN(_pnUser) { if(!$('#powerTip > div.profile ul.profile-column a.button').has('span.ico--type-mail-white').hasClass('seal--spin')) { if('pnWindow_' + _pnUser in timer) { window.clearInterval(timer['pnWindow_' + _pnUser]); delete timer['pnWindow_' + _pnUser]; } saveRestorePN(_pnUser); } } function savePN(_userPath) { save.pn[_userPath] = {message: $('#pm-message').val(), subject: $('#pm-subject').val()}; } function saveRestorePN(_pnUser, _thread_id, _initSave) { // attach Events on PN-Button var _userPath = _pnUser + (_thread_id != null ? '_' + _thread_id : ''); if(_userPath in save.pn) { $('#pm-subject').val(save.pn[_userPath].subject); $('#pm-message').val(save.pn[_userPath].message); } if(_initSave != null && _initSave) { savePN(_userPath); } $('#pm-subject, #pm-message').change(function() { savePN(_userPath); }); $('div.modalWin-body').has('#pm-message').find('form.form').submit(function () { if(_userPath in save.pn) { delete save.pn[_userPath]; } timer['pnSent_' + _userPath] = window.setInterval(function () { waitForPNSent(_pnUser, _thread_id) }, 50); }); } function waitForPNSent(_pnUser, _thread_id) { GM_log('Waiting for PN sent'); var _form = $('#template-modal .modalWin').has('#pm-subject').find('form.form'); if(!_form.hasClass('seal--spin')) { var _userPath = _pnUser + (_thread_id != null ? '_' + _thread_id : ''); if('pnSent_' + _userPath in timer) { window.clearInterval(timer['pnSent_' + _userPath]); delete timer['pnSent_' + _userPath]; } var _success = _form.find('.message').eq(0).hasClass('message--type-success'); GM_log('Gesendet: ' + _success); if(_success) { $('#template-modal .modalWin').html('').removeClass('modalWin'); $(document.body).removeClass('modal--active'); createMessageWindow('Nachricht verschickt!', 'success'); } else { saveRestorePN(_pnUser, _thread_id, true); } } } 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.replace(/\
    \[edit_reasons\][^]+\[\/edit_reasons\]/m, '') + '[/quote]'; // vom HUKD Toolkit (Danke an lolnickname) /* Zeilenwechsel entfernen */ _comment = _comment.replace(/^\s+$/g, ''); while(/\n\r?\n/m.test(_comment)) { _comment = _comment.replace(/\n\r?\n/m,"\n"); } /* mehrfache Leerzeichen */ while(/(\S)[^\S\r\n]{2,}(\S)/.test(_comment)) { _comment = _comment.replace(/(\S)[^\S\r\n]{2,}(\S)/g,"$1 $2"); } /* 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 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.comments.maxQuoteLevel; if (_quoteStartCount <= _maxQuoteLevel) { return _quoteContent; } var _startPos = new Array(); var _endPos = new Array(); var _positions = Array(); for (var _i = 0; _i < _quoteStartCount; _i++) { _positions.push({pos: _quoteContent.indexOf(_quoteStarts[_i], _startPos[_i-1] + 1), type: 'start', match: _quoteStarts[_i]}); _startPos[_i] = _quoteContent.indexOf(_quoteStarts[_i], _startPos[_i-1] + 1); _positions.push({pos: _quoteContent.indexOf(_quoteEnds[_i], _endPos[_i-1] + 1), type: 'end', match: _quoteEnds[_i]}); _endPos[_i] = _quoteContent.indexOf(_quoteEnds[_i], _endPos[_i-1] + 1); } delete _startPos; delete _endPos; var _curQuoteLevel = 0; var _reducedQuote = ''; var _startSnippet = 0; _positions.sort(function (_a, _b) { return _a.pos - _b.pos; }); for(_i = 0; _i < _positions.length; _i++) { if(_positions[_i].type == 'start') { if(_curQuoteLevel == _maxQuoteLevel) { _reducedQuote += _quoteContent.substring(_startSnippet, _positions[_i].pos); } _curQuoteLevel++; } else { _curQuoteLevel--; if(_curQuoteLevel == _maxQuoteLevel) { _startSnippet = _positions[_i].pos + _positions[_i].match.length; } } } _reducedQuote += _quoteContent.substr(_startSnippet); 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 modifyListings() { var _elems = $('li.thread'); if(_elems.length && settings.deals.hide.length) { _elems.each(function (_eInd, _eVal) { if((new RegExp(settings.deals.hide, 'i')).test($(_eVal).find('.thread-head .section-title-link').text())) { $(_eVal).remove(); } }); } } function addScrollUpButton() { var _newElem = $('').attr('id', 'scrollUpButton').append($('
    ').addClass('tGrid tGrid tGrid--auto').append($('