|
@ -126,6 +126,9 @@ function enableSoftTransitions( element ){ |
|
|
//night mode
|
|
|
//night mode
|
|
|
function nightMode(){ |
|
|
function nightMode(){ |
|
|
|
|
|
|
|
|
|
|
|
if( hasComments()) |
|
|
|
|
|
setInvertCommentImages(); |
|
|
|
|
|
|
|
|
if( isNightTime() ){ |
|
|
if( isNightTime() ){ |
|
|
toggleNight("on"); |
|
|
toggleNight("on"); |
|
|
} |
|
|
} |
|
@ -143,19 +146,31 @@ function isNightTime(){ |
|
|
else |
|
|
else |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
function hasComments(){ |
|
|
|
|
|
return jQuery("#gcomment-widget-jsid-comment-sys").length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function toggleNight( command ){ |
|
|
function toggleNight( command ){ |
|
|
|
|
|
|
|
|
nightClass = "night"; |
|
|
nightClass = "night"; |
|
|
var container = jQuery('#container'); |
|
|
var container = jQuery('#container'); |
|
|
|
|
|
|
|
|
|
|
|
if( hasComments()) |
|
|
|
|
|
var commentPosts = frames['gcomment-widget-jsid-comment-sys'].document.getElementsByClassName("post-comment")[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( command ){ |
|
|
if( command ){ |
|
|
switch( command ){ |
|
|
switch( command ){ |
|
|
case 'on': |
|
|
case 'on': |
|
|
container.addClass( nightClass ); |
|
|
container.addClass( nightClass ); |
|
|
|
|
|
if( hasComments()) |
|
|
|
|
|
addClass( commentPosts, nightClass ); |
|
|
break; |
|
|
break; |
|
|
case 'off': |
|
|
case 'off': |
|
|
container.removeClass( nightClass ); |
|
|
container.removeClass( nightClass ); |
|
|
|
|
|
if( hasComments()) |
|
|
|
|
|
removeClass( commentPosts, nightClass ); |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
}else{ |
|
|
}else{ |
|
@ -168,6 +183,17 @@ function toggleNight( command ){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setInvertCommentImages(){ |
|
|
|
|
|
// jQuery( "img", frames['gcomment-widget-jsid-comment-sys'].document ).css({"-webkit-filter" : "invert(100%)"});
|
|
|
|
|
|
|
|
|
|
|
|
var cssLink = document.createElement("link") |
|
|
|
|
|
cssLink.href = chrome.extension.getURL("style.css"); |
|
|
|
|
|
cssLink.rel = "stylesheet"; |
|
|
|
|
|
cssLink.type = "text/css"; |
|
|
|
|
|
frames['gcomment-widget-jsid-comment-sys'].document.body.appendChild(cssLink); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function showNSFW(){ |
|
|
function showNSFW(){ |
|
|
jQuery(".badge-nsfw-entry-cover").each(function() { |
|
|
jQuery(".badge-nsfw-entry-cover").each(function() { |
|
|
jQuery(this).addClass("deobfuscated"); |
|
|
jQuery(this).addClass("deobfuscated"); |
|
@ -187,6 +213,7 @@ function NSFWListener(){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//init everything
|
|
|
//init everything
|
|
|
|
|
|
|
|
|
jQuery(document).ready(function() { |
|
|
jQuery(document).ready(function() { |
|
|
updatingDom = false; |
|
|
updatingDom = false; |
|
|
showNSFW(); |
|
|
showNSFW(); |
|
@ -204,7 +231,6 @@ jQuery(document).ready(function() { |
|
|
|
|
|
|
|
|
setupSidebar(); |
|
|
setupSidebar(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nightMode(); |
|
|
nightMode(); |
|
|
setLilikLogo(); |
|
|
setLilikLogo(); |
|
|
|
|
|
|
|
@ -226,3 +252,19 @@ chrome.extension.onMessage.addListener( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// javascript utils to manipulate classes:
|
|
|
|
|
|
// necessary to hack the comments css
|
|
|
|
|
|
|
|
|
|
|
|
function hasClass(ele,cls) { |
|
|
|
|
|
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); |
|
|
|
|
|
} |
|
|
|
|
|
function addClass(ele,cls) { |
|
|
|
|
|
if (!this.hasClass(ele,cls)) ele.className += " "+cls; |
|
|
|
|
|
} |
|
|
|
|
|
function removeClass(ele,cls) { |
|
|
|
|
|
if (hasClass(ele,cls)) { |
|
|
|
|
|
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); |
|
|
|
|
|
ele.className=ele.className.replace(reg,' '); |
|
|
|
|
|
} |
|
|
|
|
|
} |