// ==UserScript== // @name Tuning diit.cz ;) // @namespace http://sob.hisoftware.cz/ // @description Prekopani diit.cz (vzhled diskusi, zvyraznovani novych prispevku, ...) // @include http://diit.cz/* // @include http://cdr.cz/* // @grant none // ==/UserScript== var css = new Array(); function writeStyle(css) { var style = document.createElement('style'); style.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(style); for(var i = 0; i < css.length; i++) { style.sheet.insertRule(css[i], 0); } } function addStyle(style) { css[css.length] = style; } // barva pisma addStyle("body { color: #303030; }"); // diskuse - zaklad var match=/^http:\/\/cdr\.cz\//.exec(window.location); if(match) { addStyle(".view-id-diit_comments .views-row-odd { background-color: #F7F9FA; }"); addStyle(".view-id-diit_comments .views-row-even { background-color: #FDFFFF; }"); addStyle(".view-id-diit_comments .views-row-odd.new-comment { background-color: #D2E3EC; }"); addStyle(".view-id-diit_comments .views-row-even.new-comment { background-color: #D7E8F0; }"); addStyle(".view-content { margin: 0px 20px; }"); } else { addStyle(".view-id-diit_comments .views-row-odd { background-color: #E8EAEB; }"); addStyle(".view-id-diit_comments .views-row-even { background-color: #EEEFEF; }"); addStyle(".view-id-diit_comments .views-row-odd.new-comment { background-color: #EAE2DB; }"); addStyle(".view-id-diit_comments .views-row-even.new-comment { background-color: #EFE6DF; }"); } addStyle(".view-id-diit_comments .views-field-nothing { display: none; }"); addStyle(".view-id-diit_comments .views-row { margin-top: 0px !important; margin-bottom: 0px !important; padding: 5px 0px 8px 10px !important; position: relative; }"); addStyle(".view-id-diit_comments .views-field-comment { padding-right: 10px !important; padding-bottom: 0px !important; }"); addStyle(".view-id-diit_comments .views-field-replyto-comment { float: none !important; display: block !important; position: absolute; right: 0px; top: 5px; }"); addStyle(".view-id-diit_comments .field-content > p:last-child { margin-bottom: 0px !important; }"); addStyle(".view-id-diit_comments .views-row > .children { padding-top: 8px; margin-bottom: -8px !important; }"); // diskuse - oprava odsazeni addStyle(".view-id-diit_comments .children { margin-left: -10px !important; }"); addStyle(".view-id-diit_comments .children .views-row { margin-left: 0px !important; }"); addStyle(".view-id-diit_comments .views-field-name, .views-field-comment { padding-left: 0px; }"); addStyle(".view-id-diit_comments .children .views-field-name { padding-left: 15px; }"); addStyle(".view-id-diit_comments .children .moderator-4 .views-field-name { padding-left: 35px !important; background-position: 15px 0px !important; }"); addStyle(".view-id-diit_comments .children .views-field-comment { padding-left: 15px !important; }"); addStyle(".view-id-diit_comments .children .children .views-field-name { padding-left: 30px; }"); addStyle(".view-id-diit_comments .children .children .moderator-4 .views-field-name { padding-left: 50px !important; background-position: 30px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .views-field-comment { padding-left: 30px !important; }"); addStyle(".view-id-diit_comments .children .children .children .views-field-name { padding-left: 45px; }"); addStyle(".view-id-diit_comments .children .children .children .moderator-4 .views-field-name { padding-left: 65px !important; background-position: 45px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .views-field-comment { padding-left: 45px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .views-field-name { padding-left: 60px; }"); addStyle(".view-id-diit_comments .children .children .children .children .moderator-4 .views-field-name { padding-left: 80px !important; background-position: 60px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .views-field-comment { padding-left: 60px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .views-field-name { padding-left: 75px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 95px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .views-field-comment { padding-left: 75px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .views-field-name { padding-left: 90px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 110px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .views-field-comment { padding-left: 90px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .views-field-name { padding-left: 105px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 125px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .views-field-comment { padding-left: 105px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .views-field-name { padding-left: 120px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 140px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .views-field-comment { padding-left: 120px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .views-field-name { padding-left: 135px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 155px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .views-field-comment { padding-left: 135px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .views-field-name { padding-left: 150px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 170px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .views-field-comment { padding-left: 150px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .views-field-name { padding-left: 165px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 185px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .views-field-comment { padding-left: 165px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .children .views-field-name { padding-left: 180px; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .children .moderator-4 .views-field-name { padding-left: 195px !important; background-position: 75px 0px !important; }"); addStyle(".view-id-diit_comments .children .children .children .children .children .children .children .children .children .children .children .children .views-field-comment { padding-left: 180px !important; }"); // velikost pisma //addStyle("#page { font-size: 12px; }"); // vetsi sirka webu addStyle("#page-wrapper, .region-page-closure { min-width: 970px; width: 80%; }"); addStyle("#content, .no-sidebars #content { width: auto; margin-right: 0px; }"); addStyle(".sidebar-second #content { width: auto; margin-right: 300px; }"); addStyle(".sidebar-right { margin-left: -302px; margin-right: 0px; }"); addStyle("#content-area { margin-right: 320px; }"); writeStyle(css); function findChild(parent, childClass) { if(!parent) return null; for(var i = 0; i < parent.childNodes.length; i ++) { if(parent.childNodes[i].classList && parent.childNodes[i].classList.contains(childClass)) return parent.childNodes[i]; } return null; } function showNewMessages() { var match=/^http:\/\/(diit|cdr)\.cz\/diskuze\/(\d+)/.exec(window.location); if(match && match[2]) { var id = 'diskuse-' + match[2] + '-last'; // var last = localStorage.getItem(id); if(last == null) last = 0; else last = parseInt(last); // var now = new Date(); now.setSeconds(0); localStorage.setItem(id, now.getTime()); // var tsel, time, divs = document.getElementsByTagName('div'); for(var i = 0; i < divs.length; i ++) { if(true) { //divs[i].id.match(/^comment\-/)) { tsel = findChild(divs[i], 'views-field-timestamp'); if(!tsel) tsel = findChild(divs[i].childNodes[1], 'views-field-timestamp'); if(tsel) { match = /(\d+)\.(\d+)\.(\d+)\ -\ (\d+):(\d+)/.exec(tsel.childNodes[1].innerHTML); time = new Date(); time.setDate(match[1]); time.setMonth(match[2] - 1); time.setYear(match[3]); time.setHours(match[4]); time.setMinutes(match[5]); time.setSeconds(0); time = time.getTime(); if(/*last > 0 &&*/ time >= last) { divs[i].parentNode.classList.add('new-comment'); } } } } } } showNewMessages(); //@EOF