';
try{
var malUrl = GM_getValue(K.dbSelector+'/'+$.titleToDbKey(K.urlAnimeSelector(K.normalUrl()))+'/Mal' , null);
}catch(e){
var malUrl = null;
}
if(malUrl == url){
settingsUI += '
\
\
';
if(data != null && data != '404'){
settingsUI += data.split('itemprop="name">')[1].split('<')[0];
}else{
settingsUI += 'Not Found';
}
settingsUI +=
' \
\
\
\
\
Episode Offset \
'+getTooltip('Input the episode offset, if an anime has 12 episodes, but uses the numbers 0-11 rather than 1-12, you simply type " +1 " in the episode offset.','float: right; margin-top: -17px;','left')+'\
\
\
\
\
\
MyAnimeList Url \
'+getTooltip('Only change this URL if it points to the wrong anime page on MAL.','float: right; margin-top: -17px;','left')+'\
\
\
\
\
\
\
Search\
\
\
'+getTooltip('This field is for finding an anime, when you need to replace the "MyAnimeList Url" shown above. To make a search, simply begin typing the name of an anime, and a list with results will automatically appear as you type.','float: right; margin-top: -17px;','left')+'\
\
\
\
\
\
Update \
Reset \
\
';
}
settingsUI += '
\
\
General \
';
settingsUI += materialCheckbox(autoTracking,'autoTracking','Autotracking'+getTooltip('Autotracking is the function where this script automatically updates the anime´s you watch with your MAL account.','','bottom'));
settingsUI += '
\
\
\
Autotracking delay (Seconds) \
\
';
settingsUI += '
';
settingsUI += '
\
\
MAL Bookmark Page \
';
settingsUI += materialCheckbox(tagLinks,'tagLinks','Continue watching links'+getTooltip('If enabled: On your MAL Anime List and the bookmark list in miniMAL, an icon-link will be added to the last used streaming site you were using to watch an anime.
Simply click the icon to continue watching the anime.'));
settingsUI += materialCheckbox(epPredictions,'epPredictions','Predict episode number');
settingsUI += '
\
\
Check for new episodes\
\
\
\
Off \
1 Hour \
12 Hour \
Always \
\
\
';
settingsUI += '
\
\
Border Color
\
\
\
\
Custom \
Red \
MAL Blue \
Off \
\
\
\
';
settingsUI += materialCheckbox(newEpNotification,'newEpNotification','Notifications');
settingsUI += materialCheckbox(openInBg,'openInBg','Load cookies in background');
settingsUI += materialCheckbox(newEpCR,'newEpCR','CR-Unblocker Extension');
settingsUI += '
';
settingsUI += '
\
\
Streaming Site Links ';
settingsUI += getTooltip('If disabled, the streaming site will no longer appear in an animes sidebar on MAL.');
settingsUI += '';
settingsUI += materialCheckbox(kissanimeLinks,'kissanimeLinks','KissAnime');
settingsUI += materialCheckbox(masteraniLinks,'masteraniLinks','MasterAnime');
settingsUI += materialCheckbox(nineanimeLinks,'nineanimeLinks','9anime');
settingsUI += materialCheckbox(crunchyrollLinks,'crunchyrollLinks','Crunchyroll');
settingsUI += materialCheckbox(gogoanimeLinks,'gogoanimeLinks','Gogoanime');
settingsUI += materialCheckbox(kissmangaLinks,'kissmangaLinks','KissManga');
settingsUI += materialCheckbox(mangadexLinks,'mangadexLinks','MangaDex');
settingsUI += '
';
settingsUI += '
\
\
MyAnimeList \
';
settingsUI += '
\
\
Thumbnails\
'+getTooltip('The option is for resizing the thumbnails on MAL. Like thumbnails for characters, people, recommendations, etc.')+'\
\
\
\
Large \
Medium \
Small \
MAL Default \
\
\
';
settingsUI += materialCheckbox(mangaStore,'mangaStore','Hide Manga Store');
settingsUI += '
';
settingsUI += '
\
\
miniMAL \
Shortcut: Ctrl + m \
';
settingsUI += '
\
\
Display to the\
\
\
\
Left \
Right \
\
\
';
settingsUI += materialCheckbox(miniMALonMal,'miniMALonMal','Display on MyAnimeList');
settingsUI += materialCheckbox(displayFloatButton,'displayFloatButton','Floating menu button');
settingsUI += materialCheckbox(outWay,'outWay','Move video out of the way');
settingsUI += '
\
\
\
Height (px / %)\
\
\
';
settingsUI += '
\
\
\
Width (px / %) \
\
';
settingsUI += '
';
settingsUI += '
';
settingsUI += materialCheckbox(episodeInfoBox,'episodeInfoBox','Episode Hoverinfo'+getTooltip('
'), true);
settingsUI += '
';
settingsUI += materialCheckbox(episodeInfoSynopsis,'episodeInfoSynopsis','Synopsis'+getTooltip('If enabled, the episode-synopsis from MAL will be displayed in the Episode Hoverinfo.'));
settingsUI += materialCheckbox(episodeInfoImage,'episodeInfoImage','Image'+getTooltip('If enabled, the episode-image from MAL will be displayed in the Episode Hoverinfo.'));
settingsUI += materialCheckbox(episodeInfoSubtitle,'episodeInfoSubtitle','Alternative Title'+getTooltip('If enabled, the alternative title for the episode, will be displayed in the Episode Hoverinfo. Example using the anime "Fate/Apocrypha":
Title: "Apocrypha: The Great Holy Grail War"
Subtitle: "Gaiten: Seihai Taisen (外典:聖杯大戦)"'));
settingsUI += '
';
settingsUI += '
\
\
ETC \
';
settingsUI += materialCheckbox(debugging,'debugging','Debugging');
settingsUI += '
Clear Cache ';
settingsUI += '
';
$("#info-iframe").contents().find('#malConfig').html(settingsUI);
$("#info-iframe").contents().find("#malReset").click( function(){
GM_deleteValue( K.dbSelector+'/'+$.titleToDbKey(K.urlAnimeSelector(K.normalUrl()))+'/Mal' );
flashm( "MyAnimeList url reset" , false);
checkdata();
});
$("#info-iframe").contents().find("#malSubmit").click( function(){
var murl = $("#info-iframe").contents().find("#malUrlInput").val();
local_setValue(K.normalUrl(), murl, true);
flashm( "new url '"+murl+"' set." , false);
checkdata();
});
$("#info-iframe").contents().find("#malDelay").on("input", function(){
var tempDelay = $("#info-iframe").contents().find("#malDelay").val();
if(tempDelay !== null){
if(tempDelay !== ''){
delay = tempDelay;
GM_setValue( 'delay', tempDelay );
flashm( "New delay ("+delay+") set." , false);
}else{
delay = 3;
GM_deleteValue( 'delay' );
flashm( "Delay reset" , false);
}
}
});
$("#info-iframe").contents().find("#miniMalWidth").on("input", function(){
var miniMalWidth = $("#info-iframe").contents().find("#miniMalWidth").val();
if(miniMalWidth !== null){
if(miniMalWidth !== ''){
GM_setValue( 'miniMalWidth', miniMalWidth );
flashm( "New Width ("+miniMalWidth+") set." , false);
}else{
miniMalWidth = '30%';
GM_deleteValue( 'miniMalWidth' );
flashm( "Width reset" , false);
}
}
$("#modal-content").css('width', miniMalWidth);
});
$("#info-iframe").contents().find("#miniMalHeight").on("input", function(){
var miniMalHeight = $("#info-iframe").contents().find("#miniMalHeight").val();
if(miniMalHeight !== null){
if(miniMalHeight !== ''){
GM_setValue( 'miniMalHeight', miniMalHeight );
flashm( "New Height ("+miniMalHeight+") set." , false);
}else{
miniMalHeight = '90%';
GM_deleteValue( 'miniMalHeight' );
flashm( "Height reset" , false);
}
}
$("#modal-content").css('height', miniMalHeight);
});
$("#info-iframe").contents().find("#malOffset").on("input", function(){
var Offset = $("#info-iframe").contents().find("#malOffset").val();
if(Offset !== null){
if(Offset !== ''){
GM_setValue( K.dbSelector+'/'+$.titleToDbKey(K.urlAnimeSelector(K.normalUrl()))+'/Offset', Offset );
flashm( "New Offset ("+Offset+") set." , false);
}else{
GM_deleteValue( K.dbSelector+'/'+$.titleToDbKey(K.urlAnimeSelector(K.normalUrl()))+'/Offset' );
flashm( "Offset reset" , false);
}
}
});
var timer;
$("#info-iframe").contents().find("#malSearch").on("input", function(){
clearTimeout(timer);
timer = setTimeout(function(){
searchMal( $("#info-iframe").contents().find("#malSearch").val(), K.listType, '.malResults', function(){
$("#info-iframe").contents().find("#malSearchResults .searchItem").unbind('click').click(function(event) {
$("#info-iframe").contents().find('#malUrlInput').val($(this).attr('malhref'));
$("#info-iframe").contents().find('#malSearch').val('');
$("#info-iframe").contents().find('#malSearchResults').html('');
});
});
}, 300);
});
$("#info-iframe").contents().find("#clearCache").click( function(){
clearCache();
});
$("#info-iframe").contents().find('#autoTracking').change(function(){
if($(this).is(":checked")){
GM_setValue('autoTracking', 1);
autoTracking = 1;
}else{
GM_setValue('autoTracking', 0);
autoTracking = 0;
}
});
$("#info-iframe").contents().find('#tagLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('tagLinks', 1);
tagLinks = 1;
}else{
GM_setValue('tagLinks', 0);
tagLinks = 0;
}
});
$("#info-iframe").contents().find('#newEpNotification').change(function(){
if($(this).is(":checked")){
GM_setValue('newEpNotification', 1);
newEpNotification = 1;
}else{
GM_setValue('newEpNotification', 0);
newEpNotification = 0;
}
});
$("#info-iframe").contents().find('#openInBg').change(function(){
if($(this).is(":checked")){
GM_setValue('openInBg', 1);
openInBg = 1;
}else{
GM_setValue('openInBg', 0);
openInBg = 0;
}
});
$("#info-iframe").contents().find('#newEpCR').change(function(){
if($(this).is(":checked")){
alert('Only activate this option if you have the Extension CR-Unblocker installed!');
GM_setValue('newEpCR', 1);
newEpCR = 1;
}else{
GM_setValue('newEpCR', 0);
newEpCR = 0;
}
});
$("#info-iframe").contents().find('#kissmangaLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('kissmangaLinks', 1);
kissmangaLinks = 1;
}else{
GM_setValue('kissmangaLinks', 0);
kissmangaLinks = 0;
}
});
$("#info-iframe").contents().find('#mangadexLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('mangadexLinks', 1);
mangadexLinks = 1;
}else{
GM_setValue('mangadexLinks', 0);
mangadexLinks = 0;
}
});
$("#info-iframe").contents().find('#kissanimeLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('kissanimeLinks', 1);
kissanimeLinks = 1;
}else{
GM_setValue('kissanimeLinks', 0);
kissanimeLinks = 0;
}
});
$("#info-iframe").contents().find('#masteraniLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('masteraniLinks', 1);
masteraniLinks = 1;
}else{
GM_setValue('masteraniLinks', 0);
masteraniLinks = 0;
}
});
$("#info-iframe").contents().find('#nineanimeLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('nineanimeLinks', 1);
nineanimeLinks = 1;
}else{
GM_setValue('nineanimeLinks', 0);
nineanimeLinks = 0;
}
});
$("#info-iframe").contents().find('#crunchyrollLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('crunchyrollLinks', 1);
crunchyrollLinks = 1;
}else{
GM_setValue('crunchyrollLinks', 0);
crunchyrollLinks = 0;
}
});
$("#info-iframe").contents().find('#gogoanimeLinks').change(function(){
if($(this).is(":checked")){
GM_setValue('gogoanimeLinks', 1);
gogoanimeLinks = 1;
}else{
GM_setValue('gogoanimeLinks', 0);
gogoanimeLinks = 0;
}
});
$("#info-iframe").contents().find("#posLeft").val(posLeft);
$("#info-iframe").contents().find("#posLeft").change(function(){
GM_setValue( 'posLeft', $("#info-iframe").contents().find("#posLeft").val() );
});
$("#info-iframe").contents().find('#displayFloatButton').change(function(){
if($(this).is(":checked")){
GM_setValue('displayFloatButton', 1);
displayFloatButton = 1;
}else{
GM_setValue('displayFloatButton', 0);
displayFloatButton = 0;
}
});
$("#info-iframe").contents().find('#episodeInfoBox').change(function(){
if($(this).is(":checked")){
GM_setValue('episodeInfoBox', 1);
episodeInfoBox = 1;
}else{
GM_setValue('episodeInfoBox', 0);
episodeInfoBox = 0;
}
});
$("#info-iframe").contents().find('#episodeInfoSynopsis').change(function(){
if($(this).is(":checked")){
GM_setValue('episodeInfoSynopsis', 1);
episodeInfoSynopsis = 1;
}else{
GM_setValue('episodeInfoSynopsis', 0);
episodeInfoSynopsis = 0;
}
});
$("#info-iframe").contents().find('#episodeInfoImage').change(function(){
if($(this).is(":checked")){
GM_setValue('episodeInfoImage', 1);
episodeInfoImage = 1;
}else{
GM_setValue('episodeInfoImage', 0);
episodeInfoImage = 0;
}
});
$("#info-iframe").contents().find('#episodeInfoSubtitle').change(function(){
if($(this).is(":checked")){
GM_setValue('episodeInfoSubtitle', 1);
episodeInfoSubtitle = 1;
}else{
GM_setValue('episodeInfoSubtitle', 0);
episodeInfoSubtitle = 0;
}
});
$("#info-iframe").contents().find('#miniMALonMal').change(function(){
if($(this).is(":checked")){
GM_setValue('miniMALonMal', 1);
miniMALonMal = 1;
}else{
GM_setValue('miniMALonMal', 0);
miniMALonMal = 0;
}
});
$("#info-iframe").contents().find('#outWay').change(function(){
if($(this).is(":checked")){
GM_setValue('outWay', 1);
outWay = 1;
}else{
GM_setValue('outWay', 0);
outWay = 0;
}
});
$("#info-iframe").contents().find("#malThumbnail").val(malThumbnail);
$("#info-iframe").contents().find("#malThumbnail").change(function(){
GM_setValue( 'malThumbnail', $("#info-iframe").contents().find("#malThumbnail").val() );
});
$("#info-iframe").contents().find('#mangaStore').change(function(){
if($(this).is(":checked")){
GM_setValue('mangaStore', 1);
mangaStore = 1;
}else{
GM_setValue('mangaStore', 0);
mangaStore = 0;
}
});
$("#info-iframe").contents().find('#debugging').change(function(){
if($(this).is(":checked")){
GM_setValue('debugging', 1);
debugging = 1;
}else{
GM_setValue('debugging', 0);
debugging = 0;
}
});
$("#info-iframe").contents().find('#epPredictions').change(function(){
if($(this).is(":checked")){
GM_setValue('epPredictions', 1);
epPredictions = 1;
}else{
GM_setValue('epPredictions', 0);
epPredictions = 0;
}
});
$("#info-iframe").contents().find("#newEpInterval").val(newEpInterval);
$("#info-iframe").contents().find("#newEpInterval").change(function(){
GM_setValue( 'newEpInterval', $("#info-iframe").contents().find("#newEpInterval").val() );
});
$("#info-iframe").contents().find("#newEpBorder").change(function(){
GM_setValue( 'newEpBorder', $("#info-iframe").contents().find("#newEpBorder").val() );
$("#info-iframe").contents().find('#newEpBorder_color').css('background-color', '#'+$("#info-iframe").contents().find("#newEpBorder").val());
});
$("#info-iframe").contents().find("#newEpBorder_dropdown").val(newEpBorder);
$("#info-iframe").contents().find("#newEpBorder_dropdown").change(function(){
var dvalue= $("#info-iframe").contents().find("#newEpBorder_dropdown").val();
if(dvalue == 'c'){
$("#info-iframe").contents().find("#newEpBorder").show();
}else{
$("#info-iframe").contents().find("#newEpBorder").hide();
$("#info-iframe").contents().find("#newEpBorder").val( dvalue );
$("#info-iframe").contents().find("#newEpBorder").trigger("change");
if(dvalue == ' '){
$("#info-iframe").contents().find('#newEpBorder_color').css('background-color','transparent');
}
}
});
$("#info-iframe").contents().find("#newEpBorder_dropdown").trigger("change");
$("#info-iframe").contents().find('#malConfig').show();
}catch(e) {console.log('[iframeConfig] Error:',e);}
}
function iframeOverview(url, data){
$("#info-iframe").contents().find('#loadOverview').hide();
try{
var image = data.split('js-scrollfix-bottom')[1].split('
')[1].split('<')[0];
$("#info-iframe").contents().find('.malTitle').html(title).show();
$("#info-iframe").contents().find('.coverinfo').show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
$("#info-iframe").contents().find('.malLink').attr('href',url).show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var description = data.split('itemprop="description">')[1].split(''+description+'').show();
$("#info-iframe").contents().find('.coverinfo').show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var statsBlock = data.split('
Statistics ')[1].split('
')[0];
var html = $.parseHTML( statsBlock );
var statsHtml = '';
$.each($(html).filter('div').slice(0,5), function( index, value ) {
statsHtml += '';
statsHtml += '';
statsHtml += '';
statsHtml += $(this).find('.dark_text').text();
statsHtml += ' ';
statsHtml += '';
statsHtml += $(this).find('span[itemprop=ratingValue]').height() != null ? $(this).find('span[itemprop=ratingValue]').text() : $(this).clone().children().remove().end().text();
statsHtml += ' ';
statsHtml += ' ';
statsHtml += ' ';
});
statsHtml += ' ';
$("#info-iframe").contents().find('.stats-block').html(statsHtml).show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var altTitle = data.split('Alternative Titles ')[1].split('')[0];
altTitle = altTitle.replace(/spaceit_pad/g,'mdl-chip" style="margin-right: 5px;');
$("#info-iframe").contents().find('.malAltTitle').html(altTitle);
$("#info-iframe").contents().find('.malAltTitle .mdl-chip').contents().filter(function() {
return this.nodeType == 3 && $.trim(this.textContent) != '';
}).wrap(' ');
$("#info-iframe").contents().find('.malAltTitle').show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var infoBlock = data.split('Information ')[1].split('')[0];
var html = $.parseHTML( infoBlock );
var infoHtml = '';
$.each($(html).filter('div'), function( index, value ) {
if((index + 4) % 4 == 0 && index != 0){
//infoHtml +=' ';
}
infoHtml += '';
infoHtml += '';
infoHtml += '';
infoHtml += $(this).find('.dark_text').text();
infoHtml += ' ';
infoHtml += '';
$(this).find('.dark_text').remove();
infoHtml += $(this).html();
//$(this).find('*').each(function(){infoHtml += $(this)[0].outerHTML});
//infoHtml += $(this).find('span[itemprop=ratingValue]').height() != null ? $(this).find('span[itemprop=ratingValue]').text() : $(this).clone().children().remove().end().text();
infoHtml += ' ';
infoHtml += ' ';
infoHtml += ' ';
});
infoHtml += ' ';
$("#info-iframe").contents().find('.info-block').html(infoHtml).show();
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var relatedBlock = data.split('Related ')[1].split(' ')[1].split('')[0];
var related = $.parseHTML( relatedBlock );
var relatedHtml = '';
$.each($(related).filter('table').find('tr'), function( index, value ) {
relatedHtml += '';
relatedHtml += '';
relatedHtml += '';
relatedHtml += $(this).find('.borderClass').first().text();
relatedHtml += ' ';
relatedHtml += '';
relatedHtml += $(this).find('.borderClass').last().html();
relatedHtml += ' ';
relatedHtml += ' ';
relatedHtml += ' ';
});
relatedHtml += ' ';
$("#info-iframe").contents().find('.related-block').html(relatedHtml).show();
$("#info-iframe").contents().find('.related-block .mdl-list__item-sub-title').each(function(){$(this).html($(this).children()); });
$("#info-iframe").contents().find('#material .related-block a').each(function() {
$(this).click(function(e) {
$("#info-iframe").contents().find('.malClear').hide();
$("#info-iframe").contents().find('.mdl-progress__indeterminate').show();
$("#info-iframe").contents().find("#backbutton").show();
$("#info-iframe").contents().find('#SearchButton').css('margin-left', '-17px');
$("#info-iframe").contents().find('#book').css('left', '40px');
fillIframe($(this).attr('href'));
}).attr('onclick','return false;');
});
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var localListType = url.split('/')[3];
var dataBlock = data.split('id="addtolist"')[1].split('") + 1);
}
$("#info-iframe").contents().find('.data-block').html(dataBlock).show();
$("#info-iframe").contents().find('.data-block tr:not(:last-child)').each(function(){
var label = $(this).find('.spaceit').first().text();
//$(this).find('.spaceit').first().html('
'+label+' ');
$(this).replaceWith($('
\
\
'+label+' \
'+$(this).find('.spaceit').last().html()+' \
\
\ '));
});
$("#info-iframe").contents().find('#myinfo_status,#myinfo_score').addClass('mdl-textfield__input').css('outline', 'none');
$("#info-iframe").contents().find('#myinfo_watchedeps,#myinfo_chapters,#myinfo_volumes').addClass('mdl-textfield__input').css('width','35px').css('display','inline-block');
$("#info-iframe").contents().find('.inputButton').addClass('mdl-button mdl-js-button mdl-button--raised mdl-button--colored').css('margin-right','5px');
$("#info-iframe").contents().find('.data-block li').last().after('
'+$("#info-iframe").contents().find('.inputButton').first().parent().html()+' ');
$("#info-iframe").contents().find('.data-block tr').remove();
$("#info-iframe").contents().find('.js-'+localListType+'-update-button, .js-'+localListType+'-add-button').click(function (){
var anime = {};
if(localListType == 'anime'){
anime['.add_anime[num_watched_episodes]'] = parseInt($("#info-iframe").contents().find('#myinfo_watchedeps').val() );
if(isNaN(anime['.add_anime[num_watched_episodes]'])){
anime['.add_anime[num_watched_episodes]'] = 0;
}
}else{
anime['.add_manga[num_read_volumes]'] = parseInt($("#info-iframe").contents().find('#myinfo_volumes').val() );
if(isNaN(anime['.add_manga[num_read_volumes]'])){
anime['.add_manga[num_read_volumes]'] = 0;
}
anime['.add_manga[num_read_chapters]'] = parseInt($("#info-iframe").contents().find('#myinfo_chapters').val() );
if(isNaN(anime['.add_manga[num_read_chapters]'])){
anime['.add_manga[num_read_chapters]'] = 0;
}
}
anime['.add_'+localListType+'[score]'] = parseInt($("#info-iframe").contents().find('#myinfo_score').val() );
if(anime['.add_'+localListType+'[score]'] == 0){
anime['.add_'+localListType+'[score]'] = '';
}
anime['.add_'+localListType+'[status]'] = parseInt($("#info-iframe").contents().find('#myinfo_status').val() );
if(K.isOverviewPage()){
anime['forceUpdate'] = 2;
}
anime['malurl'] = url;
setanime(url, anime, null, localListType);
});
epPrediction(url.split('/')[4], function(timestamp, airing, diffWeeks, diffDays, diffHours, diffMinutes, episode){
if(airing){
if(episode){
var titleMsg = 'Next episode estimated in '+diffDays+'d '+diffHours+'h '+diffMinutes+'m';
$("#info-iframe").contents().find('[id="curEps"]').before('
['+episode+'] ');
}
}
});
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var characterBlock = data.split('detail-characters-list')[1].split('')[0];
var html = $.parseHTML( '
\
Characters \
expand_more \
\
';
tempWrapHtml += '
';
$.each($(html).find(':not(td) > table'), function( index, value ) {
if(!index) charFound = 1;
var regexDimensions = /\/r\/\d*x\d*/g;
var charImg = $(this).find('img').first().attr("data-src");
if ( regexDimensions.test(charImg)){
charImg = charImg.replace(regexDimensions, '');
}else{
charImg = 'https://myanimelist.cdn-dena.com/images/questionmark_23.gif';
}
temphtml += '';
temphtml += '
';
temphtml += '
';
temphtml += '
';
temphtml += '
';
temphtml += '
';
temphtml += $(this).find('.borderClass .spaceit_pad').first().parent().html();
temphtml += '
';
temphtml += '
';
temphtml += '
';
});
for(var i=0; i < 10; i++){
temphtml +='';
}
if(charFound) $("#info-iframe").contents().find('.characters-block').html(tempWrapHtml).show();
$("#info-iframe").contents().find('.characters-block .clicker').one('click', function(){
$("#info-iframe").contents().find('#characterList').html(temphtml).show();
$("#info-iframe").contents().find('.characters-block .remove').remove();
fixIframeLink();
});
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
var continueHtml = '';
continueHtml +=''
continueHtml += '
'+$("#info-iframe").contents().find('#myinfo_watchedeps').val()+'
';
continueHtml +='
';
getanime(url, function(actual){
try{
if(actual['.add_'+localListType+'[tags]'].indexOf("last::") > -1 ){
var url = atobURL( actual['.add_'+localListType+'[tags]'].split("last::")[1].split("::")[0] );
$("#info-iframe").contents().find('.malDescription').first().append(continueHtml);
setStreamLinks(url, $("#info-iframe").contents().find('.malDescription').first());
$("#info-iframe").contents().find('.malDescription .stream, .malDescription .nextStream').addClass('mdl-button mdl-button--colored mdl-js-button mdl-button--raised').css('color', 'white').find('img').css('padding-bottom', '3px').css('padding-right', '6px').css('margin-left', '-3px');
if(localListType == 'anime'){
$("#info-iframe").contents().find('.malDescription .nextStream').append('Next Episode');
$("#info-iframe").contents().find('.malDescription .stream').append('Continue Watching');
}else{
$("#info-iframe").contents().find('.malDescription .nextStream').append('Continue Reading');
$("#info-iframe").contents().find('.malDescription .stream').append('Overview');
}
}
}catch(e) {console.log('[iframeOverview] Error:',e);}
}, url, url.split('/')[3]);
}catch(e) {console.log('[iframeOverview] Error:',e);}
try{
$("#info-iframe").contents().find('.stream-block-inner').html('');
setKissToMal(url);
}catch(e) {console.log('[iframeOverview] Error:',e);}
}
function iframeReview(url, data){
$("#info-iframe").contents().find('#loadReviews').hide();
try{
var reviews = data.split('Reviews ')[1].split('')[0];
var html = $.parseHTML( reviews );
var reviewsHtml = '';
$.each($(html).filter('.borderDark'), function( index, value ) {
reviewsHtml += '
';
reviewsHtml += '
';
$(this).find('.spaceit > div').css('max-width','60%');
reviewsHtml += $(this).find('.spaceit').first().html();
reviewsHtml += '
';
reviewsHtml += '
';
$(this).find('.textReadability, .textReadability > span').contents().filter(function(){
return this.nodeType == 3 && $.trim(this.nodeValue).length;
}).wrap('
');
$(this).find('br').css('line-height','10px');
reviewsHtml += $(this).find('.textReadability').html();
reviewsHtml += '
';
reviewsHtml += '
';
});
reviewsHtml += '
';
if(reviewsHtml == '
'){
reviewsHtml = 'Nothing Found ';
}
$("#info-iframe").contents().find('#malReviews').html(reviewsHtml).show();
$("#info-iframe").contents().find('.js-toggle-review-button').addClass('nojs').click(function(){
var revID = $(this).attr('data-id');
$("#info-iframe").contents().find('#review'+revID).css('display','initial');
$("#info-iframe").contents().find('#revhelp_output_'+revID).remove();
$(this).remove();
});
$("#info-iframe").contents().find('.mb8 a').addClass('nojs').click(function(){
var revID = $(this).attr('onclick').split("$('")[1].split("'")[0];
$("#info-iframe").contents().find(revID).toggle();
});
}catch(e) {console.log('[iframeReview] Error:',e);}
}
function iframeEpisode(url, data){
getAjaxData(url+'/episode', function(data){
try{
$("#info-iframe").contents().find('#loadEpisode').hide();
var episodesBlock = data.split('mt8 episode_list js-watch-episode-list ascend">')[1].split('')[0];
var episodesHtml = '';
$("#info-iframe").contents().find('#malEpisodes').html(episodesHtml).show();
$("#info-iframe").contents().find('#malEpisodes .episode-video, #malEpisodes .episode-forum').remove();
}catch(e) {console.log('[iframeEpisode] Error:',e);}
});
}
function iframeRecommendations(url, data){
getAjaxData(url+'/userrecs', function(data){
try{
$("#info-iframe").contents().find('#loadRecommendations').hide();
var recommendationsBlock = data.split('Make a recommendation')[1].split('')[1].split('';
$.each($(html).filter('.borderClass'), function( index, value ) {
recommendationsHtml += '
';
recommendationsHtml += '
';
recommendationsHtml += $(this).find('.picSurround').html();
recommendationsHtml += '
';
recommendationsHtml += '
';
recommendationsHtml += '
';
$(this).find('.button_edit, .button_add, td:eq(1) > div:eq(1) span').remove();
recommendationsHtml += $(this).find('td:eq(1) > div:eq(1)').html();
recommendationsHtml += '
';
recommendationsHtml += '
';
$(this).find('a[href^="/dbchanges.php?go=report"]').remove();
recommendationsHtml += $(this).find('.borderClass').html();
recommendationsHtml += '
';
recommendationsHtml += '
';
recommendationsHtml += (typeof $(this).find('.spaceit').html() != 'undefined') ? $(this).find('.spaceit').html() : '';
recommendationsHtml += '
';
recommendationsHtml += $(this).find('td:eq(1) > div').last().html();
recommendationsHtml += '
';
recommendationsHtml += '
';
recommendationsHtml += '
';
/*recommendationsHtml += '
';
$(this).find('.spaceit > div').css('max-width','60%');
recommendationsHtml += $(this).find('.spaceit').first().html();
recommendationsHtml += '
';
recommendationsHtml += '
';
$(this).find('.textReadability, .textReadability > span').contents().filter(function(){
return this.nodeType == 3 && $.trim(this.nodeValue).length;
}).wrap('
');
$(this).find('br').css('line-height','10px');
recommendationsHtml += $(this).find('.textReadability').html();
recommendationsHtml += '
';*/
//recommendationsHtml += $(this).html();
recommendationsHtml += '
';
});
recommendationsHtml += '
';
if(recommendationsHtml == '
'){
recommendationsHtml = 'Nothing Found ';
}
$("#info-iframe").contents().find('#malRecommendations').html(recommendationsHtml).show();
$("#info-iframe").contents().find('.js-similar-recommendations-button').addClass('nojs').click(function(){$(this).parent().find('.more').toggle();});
$("#info-iframe").contents().find('.js-toggle-recommendation-button').addClass('nojs').click(function(){
var revID = $(this).attr('data-id');
$("#info-iframe").contents().find('#recommend'+revID).css('display','initial');
$(this).remove();
});
fixIframeLink();
$("#info-iframe").contents().find('#malRecommendations a[href^="https://myanimelist.net/anime/"],#malRecommendations a[href^="https://myanimelist.net/manga/"]').each(function() {
$(this).click(function(e) {
$("#info-iframe").contents().find('.malClear').hide();
$("#info-iframe").contents().find('.mdl-progress__indeterminate').show();
$("#info-iframe").contents().find("#backbutton").show();
$("#info-iframe").contents().find('#SearchButton').css('margin-left', '-17px');
$("#info-iframe").contents().find('#book').css('left', '40px');
$("#info-iframe").contents().find('.mdl-layout__tab:eq(0) span').trigger( "click" );
fillIframe($(this).attr('href'));
}).attr('onclick','return false;');
});
$("#info-iframe").contents().find('#malRecommendations .more .borderClass').addClass('mdl-shadow--2dp').css('padding','10px');
$("#info-iframe").contents().find('.lazyload').each(function() { $(this).attr('src', $(this).attr('data-src'));});//TODO: use lazyloading
}catch(e) {console.log('[iframeRecommendations] Error:',e);}
});
}
function executejs(string){
var rawframe = document.getElementById('info-iframe');
var framedoc = rawframe.contentDocument;
if (!framedoc && rawframe.contentWindow) {
framedoc = rawframe.contentWindow.document;
}
var script = document.createElement('script');
script.type = "text/javascript";
//script.src = "https://code.getmdl.io/1.3.0/material.min.js";
script.text = string;
framedoc.body.appendChild(script);
}
function materialCheckbox(option, string, text, header = false){
var check = '';
var sty = '';
if(option == 1) check = 'checked';
if(header) sty = 'font-size: 24px; font-weight: 300; line-height: normal;';
var item = '\
\
'+text+'\
\
\
\
\
\
\
';
return item;
}
function getAjaxData(url, callback){
GM_xmlhttpRequest({
method: "GET",
url: url,
synchronous: false,
onload: function(response) {
if(response.status == 200){
callback(response.responseText);
}else{
callback('404');
}
}
});
}
function fixIframeLink(){
$("#info-iframe").contents().find('#material a').not('[href^="http"],[href^="https"],[href^="mailto:"],[href^="#"],[href^="javascript"]').each(function() {
try{
$(this).attr('href', function(index, value) {
if (value.substr(0,1) !== "/") {
value = window.location.pathname + value;
}
return "https://myanimelist.net" + value;
});
}catch(e){}
});
$("#info-iframe").contents().find('a').not(".nojs").attr('target','_blank');
}
function searchMal(keyword, type = 'all', selector, callback){
$("#info-iframe").contents().find(selector).html('');
GM_xmlhttpRequest({
method: "GET",
url: 'https://myanimelist.net/search/prefix.json?type='+type+'&keyword='+keyword+'&v=1',
synchronous: false,
onload: function(response) {
var searchResults = $.parseJSON(response.response);
$("#info-iframe").contents().find(selector).append('
\
\
Anime \
Manga \
\
');
$("#info-iframe").contents().find('#searchListType').val(type);
$("#info-iframe").contents().find('#searchListType').change(function(event) {
searchMal(keyword, $("#info-iframe").contents().find('#searchListType').val(), selector, callback)
});
$.each(searchResults, function() {
$.each(this, function() {
$.each(this, function() {
$.each(this, function() {
if(typeof this['name'] != 'undefined'){
$("#info-iframe").contents().find(selector+' > div').append('
\
\
\
'+this['name']+' \
Type: '+this['payload']['media_type']+'
\
Score: '+this['payload']['score']+'
\
Year: '+this['payload']['start_year']+'
\
\
');
}
});
});
});
});
callback();
}
});
}
function iframeBookmarks(element, state = 1, localListType = K.listType){
element.html('
');
executejs('componentHandler.upgradeDom();');
var my_watched_episodes = 'num_watched_episodes';
var series_episodes = 'anime_num_episodes';
var localPlanTo = 'Plan to Watch';
var localWatching = 'Watching'
if(localListType != 'anime'){
my_watched_episodes = 'num_read_chapters';
series_episodes = 'manga_num_chapters';
localPlanTo = 'Plan to Read';
localWatching = 'Reading'
}
var firstEl = 1;
getUserList(state, localListType, function(el, index, total){
if(firstEl){
firstEl = 0;
var bookmarkHtml = '
';
bookmarkHtml +='
\
Anime \
Manga \
';
bookmarkHtml +='
\
All \
'+localWatching+' \
Completed \
On-Hold \
Dropped \
'+localPlanTo+' \
';
//flexbox placeholder
for(var i=0; i < 10; i++){
bookmarkHtml +='
';
}
bookmarkHtml += '
'
element.html( bookmarkHtml );
$("#info-iframe").contents().find('#malSearchPop #userListType').val(localListType);
$("#info-iframe").contents().find('#malSearchPop #userListType').change(function(event) {
iframeBookmarks(element, state, $("#info-iframe").contents().find('#malSearchPop #userListType').val() );
});
$("#info-iframe").contents().find('#malSearchPop #userListState').val(state);
$("#info-iframe").contents().find('#malSearchPop #userListState').change(function(event) {
iframeBookmarks(element, $("#info-iframe").contents().find('#malSearchPop #userListState').val(), localListType);
});
}
if(!el){
element.find('#malList .listPlaceholder').first().before( '
No Entries ');
element.find('#malList .listPlaceholder').remove();
return;
}
var bookmarkElement = '';
var uid = el[localListType+'_id']
var malUrl = 'https://myanimelist.net'+el[localListType+'_url'];
var imageHi = el[localListType+'_image_path'];
var regexDimensions = /\/r\/\d*x\d*/g;
if ( regexDimensions.test(imageHi) ) {
imageHi = imageHi.replace(/v.jpg$/g, '.jpg').replace(regexDimensions, '');
}
var progressProcent = ( el[my_watched_episodes] / el[series_episodes] ) * 100;
bookmarkElement +='
';
bookmarkElement +='
';
bookmarkElement +='
'+el[localListType+'_title'];
bookmarkElement +='';
bookmarkElement +='';
bookmarkElement +=' ';
bookmarkElement +='
'+el['tags']+'
';
bookmarkElement +='
';
bookmarkElement +='
';
element.find('#malList .listPlaceholder').first().before( bookmarkElement );
var domE = element.find('#malList .e'+uid).first();
domE.click(function(event) {
$("#info-iframe").contents().find('#book').click();
$("#info-iframe").contents().find('.malClear').hide();
$("#info-iframe").contents().find('.mdl-progress__indeterminate').show();
$("#info-iframe").contents().find("#backbutton").show();
$("#info-iframe").contents().find('#SearchButton').css('margin-left', '-17px');
$("#info-iframe").contents().find('#book').css('left', '40px');
$("#info-iframe").contents().find('.mdl-layout__tab:eq(0) span').trigger( "click" );
fillIframe($(this).attr('malhref'));
});
if(domE.find('.tags').text().indexOf("last::") > -1 ){
var url = atobURL( domE.find('.tags').text().split("last::")[1].split("::")[0] );
setStreamLinks(url, domE);
if( parseInt(el['status']) === 1 ){
checkForNewEpisodes(url, domE, domE.attr('maltitle'), domE.attr('malimage'));
}
}
epPrediction(domE.attr('malhref').split('/')[4], function(timestamp, airing, diffWeeks, diffDays, diffHours, diffMinutes, episode){
if(airing){
if(episode){
var titleMsg = 'Next episode estimated in '+diffDays+'d '+diffHours+'h '+diffMinutes+'m';
var progressBar = domE.find('.mdl-progress');
var predictionProgress = ( episode / progressBar.attr('series_episodes') ) * 100;
progressBar.prepend('
');
domE.attr('title', titleMsg);
}
}
});
}
,function(){
startCheckForNewEpisodes(localListType);
},
null,
function(continueCall){
if(state == 1){
continueCall();
return;
}
var scrollable = $("#info-iframe").contents().find('#malSearchPop .simplebar-scroll-content');
var scrollDone = 0;
scrollable.scroll(function() {
if(scrollDone) return;
if(scrollable.scrollTop() + scrollable.height() > scrollable.find('.simplebar-content').height() - 100) {
scrollDone = 1;
con.log('[Bookmarks]','Loading next part');
continueCall();
}
});
});
}
var outOfTheWayLoad = 0;
function outOfTheWay(){
if(outWay != 1) return;
$(document).ready(function(){
try{
var minimalSelector = '#modal-content';
reposition();
if(outOfTheWayLoad == 0){
outOfTheWayLoad = 1;
$( window ).resize(function(){reposition();});
var lastScrollLeft = 0;
$(window).scroll(function() {
var documentScrollLeft = $(document).scrollLeft();
if (lastScrollLeft != documentScrollLeft) {
lastScrollLeft = documentScrollLeft;
reposition();
}
});
$(document).on('mozfullscreenchange webkitfullscreenchange fullscreenchange',function(){
reposition();
});
}
function reposition(){
$(K.videoSelector).css('transform', '');
if(!$(minimalSelector).is(":visible")){
return;
}
var videoLeft = $(K.videoSelector).offset().left;
var videoWidth = $(K.videoSelector).width();
var videoRight = videoLeft + videoWidth;
var minimalLeft = $(minimalSelector).offset().left;
var minimalRight = minimalLeft + $(minimalSelector).width();
var viewportWidth = $(window).width() - $(minimalSelector).width();
if( minimalLeft == $(window).scrollLeft()){
if( minimalRight > videoLeft){
var tempVideoLeft = minimalRight;
if(videoWidth > viewportWidth){
setVideo(tempVideoLeft, viewportWidth);
}else{
setVideo(tempVideoLeft, videoWidth);
}
}
}else{
if(minimalLeft < videoRight){
if(videoWidth > viewportWidth){
var tempVideoLeft = minimalLeft - viewportWidth;
setVideo(tempVideoLeft, viewportWidth);
}else{
var tempVideoLeft = minimalLeft - videoWidth;
setVideo(tempVideoLeft, videoWidth);
}
}
}
function setVideo(Left, Width){
var scale = Width / videoWidth;
Left = Left - videoLeft;
Left = Left / scale;
$(K.videoSelector).css('transform', 'scale('+scale+') translateX('+Left+'px)');
$(K.videoSelector).css('transform-origin', '0% 50%');
$(K.videoSelector).css('transition', '0s');
}
}
}catch(e){}
});
}
var newEPTime = 0;
var newEpUpdate = 0;
var checkFail = [];
var NexEpProcessed = 0;
var NexEpFinished = 0;
var newEpRetries = 0;
var checkArray = [];
function checkForNewEpisodes(url, entrySelector, title = '', img = ''){
checkArray.push(function(totalEntries){checkForNewEpisode(url, entrySelector, totalEntries, title, img);});
}
function startCheckForNewEpisodes(localListType = K.listType){
newEpRetries++;
if(newEpInterval == 'null'){
return;
}
if($('.username').first().attr('href')){
return;
}
if(!checkArray.length){
return;
}
if( $.now() - GM_getValue('newEp_last_update_'+localListType, 0) > newEpInterval){
$('body').before('
');
newEpUpdate = 1;
}
var tempArray = checkArray;
checkArray = [];
newEPTime = 0;
for(var i=0 ; i < tempArray.length ; i++){
tempArray[i](tempArray.length);
}
}
function checkForNewEpisode(url, entrySelector, totalEntries, title = '', img = ''){
var selector = '';
var hasStyle = 0;
var localListType = 'anime';
var checkAiringState = function(parsed, html){};
if($(entrySelector).attr('style')) hasStyle = 1;
if( url.indexOf("kissanime.ru") > -1 ){
selector = ".listing a";
checkAiringState = function(parsed, html){
try{
if(html.split('Status:')[1].split('<')[0].indexOf("Completed") > -1){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("kissmanga.com") > -1 ){
localListType = 'manga';
selector = ".listing a";
checkAiringState = function(parsed, html){
try{
if(html.split('Status:')[1].split('<')[0].indexOf("Completed") > -1){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("masterani.me") > -1 ){
var masterid = url.split('/')[5].split('-')[0];
url = 'https://www.masterani.me/api/anime/'+masterid+'/detailed';
selector = ".thumbnail a.title";
checkAiringState = function(parsed, html){
try{
if(parsed["info"]["status"] == 0){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("9anime.") > -1 ){
selector = ".server:first-child .episodes a";
checkAiringState = function(parsed, html){
try{
if(html.split('
Status: ')[1].split('')[0].indexOf("Completed") > -1){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("crunchyroll.com") > -1 ){
selector = "#showview_content_videos .list-of-seasons .group-item a";
checkAiringState = function(parsed, html){
try{
if(!(html.indexOf("Simulcast on") > -1)){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("gogoanime.") > -1 ){
selector = "#episode_page a:last";
checkAiringState = function(parsed, html){
try{
if(html.split('Status: ')[1].split('<')[0].indexOf("Completed") > -1){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else if( url.indexOf("mangadex.org") > -1 ){
selector = ".edit.tab-content .table-striped tbody > tr:first a";
checkAiringState = function(parsed, html){
try{
if(html.split('status:')[1].split('td')[1].split('<')[0].indexOf("Completed") > -1){
return true;
}
}catch(e){
con.log('[ERROR]',e);
}
return false;
}
}else{
checkForNewEpisodesDone(totalEntries, true);
return;
}
if( GM_getValue('newEp_'+url+'_finished', false) == true){
con.log('[EpCheck] [Finished]', title);
if(debug && !hasStyle){ $(entrySelector).attr('style', 'border-left: 4px solid green !important');}
checkForNewEpisodesDone(totalEntries, true);
return true;
}
setBorder(GM_getValue('newEp_'+url+'_cache', null));
if(newEpUpdate){
setTimeout( function(){
con.log('[EpCheck]', title, url );
GM_xmlhttpRequest({
method: "GET",
url: url,
synchronous: false,
onerror: function(response) {
con.log('[ERROR]',url+' could not be loaded');
checkForNewEpisodesDone(totalEntries, true);
},
onload: function(response) {
if(newEpCR){
if(response.response.indexOf('Your detected location is United States of America') == -1 && url.indexOf("crunchyroll.com") > -1){
response.status = 502;
}
}
if(response.status != 200){//TODO: Cloudflare handling
con.log('[EpCheck] [ERROR]', response);
var checkFailMessage = 'Coud Not Check';
if(newEpRetries < 3 && openInBg){
checkFailMessage = 'Please wait';
}
var message = '
'+checkFailMessage+'
'//;
Ok ';
if( !$('.errorpage').length ){
flashm(message,false,false,true);
}
var erClass = url.split('/')[2].replace(".", "").replace(".", "");
if(!($('.'+erClass).length)){
$('.errorpage').prepend('