Skip to content

Instantly share code, notes, and snippets.

@Juici
Forked from crapier/Kissanime_cleaner.md
Last active April 10, 2017 17:08

Revisions

  1. Juici revised this gist Nov 22, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.15.3
    // @version 3.3.15.4
    // @downloadURL https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -24,6 +24,8 @@ if (window.top != window.self) {
    // Get the pages jQuery
    var $ = unsafeWindow.jQuery;

    $(`<a class="kiss-notification" href="https://github.com/Juici/KissCleaner" style="position:fixed;bottom:20px;left:20px;width:200px;background:rgba(0,0,0,.8);color:#eee;font-family:Roboto,'Open Sans','Helvetica Neue',Helvetica,'Segoe UI',Arial,sans-serif;font-size:14px;text-decoration:none;padding:10px;">A new version of KissAnime Cleaner is available here</a>`).prependTo('#containerRoot');

    // Option constants
    var PLAYER_FLASH = 0;
    var PLAYER_HTML5 = 1;
  2. Juici revised this gist Nov 22, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    KissAnime Cleaner
    =================

    # A new rewrite of this userscript is available at https://github.com/Juici/KissCleaner
    ## A new rewrite of this userscript is available at https://github.com/Juici/KissCleaner

    This userscript for KissAnime is a fork of the [original by crapier](https://gist.github.com/crapier/91926a6353207f4524cc). It removes large chunks of the site that I do not use, including any options to login or use features only for members. I will be updating this fork as the original is updated applying fixes where neccessary and minor tweaks of my own.

  3. Juici revised this gist Nov 22, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    KissAnime Cleaner
    =================

    # A new rewrite of this userscript is available at https://github.com/Juici/KissCleaner

    This userscript for KissAnime is a fork of the [original by crapier](https://gist.github.com/crapier/91926a6353207f4524cc). It removes large chunks of the site that I do not use, including any options to login or use features only for members. I will be updating this fork as the original is updated applying fixes where neccessary and minor tweaks of my own.

    Features
  4. Juici revised this gist Nov 8, 2016. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.15.2
    // @version 3.3.15.3
    // @downloadURL https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -34,7 +34,7 @@ var quality_option = GM_getValue("quality", '1080');
    var autoplay_option = GM_getValue("auto", true);
    var autoplay_count = GM_getValue("auto_count", -1)
    var autoscroll_option = GM_getValue("scroll", true);
    var player_option = GM_getValue("player", PLAYER_FLASH);
    var player_option = GM_getValue("player", PLAYER_HTML5);
    var resize_option = GM_getValue("resize", true);
    var arrow_key_navagation = GM_getValue("arrow_nav", true);
    var speed_control = GM_getValue("speed_control", true);
    @@ -46,10 +46,10 @@ var fake_fullscreen = GM_getValue("fake_fullscreen", false);
    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /http:\/\/kissanime\.to\/$|https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|https:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$|https:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|https:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)|https:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*$|https:\/\/kissanime\.to\/Anime\/[^\/]*$|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|http:\/\/kissasian\.com\/Drama\/[^\/]*$|https:\/\/kissasian\.com\/Drama\/[^\/]*$/;
    var video_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*/;
    var home = /https?:\/\/(kissanime\.to|kisscartoon\.me|kissasian\.com)\/$/;
    var anime_list = /https?:\/\/(kissanime\.to|kisscartoon\.me|kissasian\.com)\/(AnimeList|Genre|Status|Search|UpcomingAnime|CartoonList|DramaList|Country)/;
    var anime_page = /https?:\/\/(kissanime\.to|kisscartoon\.me|kissasian\.com)\/(Anime|Cartoon|Drama)\/[^\/]*$/;
    var video_page = /https?:\/\/(kissanime\.to|kisscartoon\.me|kissasian\.com)\/(Anime|Cartoon|Drama)\/[^\/]*\/[^\/]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
  5. Juici revised this gist Sep 6, 2016. 2 changed files with 224 additions and 230 deletions.
    2 changes: 1 addition & 1 deletion Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -36,6 +36,6 @@ Only tested in FireFox with Greasemonkey (should work with Tapermonkey and Chrom
    Install
    -------
    * Get [Greasemonkey for FireFox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) if you don't already have it.
    * Click this link [KissAnime Cleaner](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js), wait 5 seconds, and click install to add the script.
    * Add [KissAnime Cleaner](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js), wait 5 seconds, and click install to add the script.

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
    452 changes: 223 additions & 229 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.15.1
    // @version 3.3.15.2
    // @downloadURL https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -58,7 +58,7 @@ if (home.test(url)) {
    console.log('Performing Cleaning for Home Page');

    // Remove Sections from the right side of the page
    //Get the rightside from the document
    // Get the rightside from the document
    var rightside = document.getElementById('rightside');
    // Check if the rightside exist and proceed if it does
    if (rightside) {
    @@ -90,7 +90,7 @@ if (home.test(url)) {
    navsub.children[0].childNodes[1].remove();
    }

    //Remove ads
    // Remove ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    leftad.remove();
    @@ -165,7 +165,7 @@ if (anime_list.test(url)) {
    adspace.parentElement.remove();
    }

    //Remove other ads
    // Remove other ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    leftad.remove();
    @@ -231,7 +231,7 @@ if (anime_page.test(url)) {
    adspace.parentElement.remove();
    }

    //Remove other ads
    // Remove other ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    leftad.remove();
    @@ -328,14 +328,14 @@ if (video_page.test(url)) {
    // Override functions so they wont be do anything when called by the pages code
    // Function to inject into page
    var override = function() {
    DoDetect2 = function() {}
    CheckAdImage = function() {}
    }
    // Create script to inject
    DoDetect2 = function() {};
    CheckAdImage = function() {};
    };
    // Create script to inject
    var script1 = document.createElement('script');
    script1.type = "text/javascript";
    script1.innerHTML = 'var override = ' + override.toString();
    // inject the script
    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script1);
    // Call our new function
    unsafeWindow.override();
    @@ -406,7 +406,6 @@ if (video_page.test(url)) {
    comments.remove();
    }


    // remove comments for kisscartoon site
    var alt_comments = document.getElementById('divComments');
    if (alt_comments) {
    @@ -431,7 +430,6 @@ if (video_page.test(url)) {
    // remove device player link and text
    $('.clsTempMSg').remove();


    var USE_FLASH_FOR_PAGE;
    var YOUTUBE_FLASH_PLAYER;
    if (player_option == PLAYER_FLASH) {
    @@ -481,68 +479,68 @@ if (video_page.test(url)) {
    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var onYouTubePlayerReady = function(playerId) {
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // translate option into youtubes quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    } else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    } else if (quality_option == '480') {
    youtube_quality_option = 'large';
    } else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // Translate option into youtube quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    } else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    } else if (quality_option == '480') {
    youtube_quality_option = 'large';
    } else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    // Set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // set the volume
    embedVideo.setVolume(volume_control);
    // Set the volume
    embedVideo.setVolume(volume_control);

    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);
    // Focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function() {
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important") + 30);
    }
    }, 100);
    }
    // Check for end of playback and move to next video
    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function() {
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important") + 30);
    }
    }, 100);
    };
    // Check for end of playback and move to next video
    var check_for_end = function(state) {
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }
    // Create script to inject
    };
    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var onYouTubePlayerReady = ' + onYouTubePlayerReady.toString() + '\n' +
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    @@ -560,15 +558,15 @@ if (video_page.test(url)) {
    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var flash_player_controls = function () {
    // wait till video is loaded into player
    // Wait till video is loaded into player
    jwplayer().onReady(function() {
    console.log("jwplayer custom Controls Initialized");
    // change the quality to desired flash option
    // Change the quality to desired flash option
    var available_levels = jwplayer().getQualityLevels();
    var level_set = false;
    var desired_level = parseInt(quality_option);

    // try to find exact quality level
    // Try to find exact quality level
    for (var i = 0; i < available_levels.length; i++) {
    if (desired_level == parseInt(available_levels[i].label)) {
    jwplayer().setCurrentQuality(i);
    @@ -577,17 +575,17 @@ if (video_page.test(url)) {
    }
    }

    // try to find best level alternate
    // Try to find best level alternate
    if (!level_set) {
    // check if desired level is lower than all available
    // Check if desired level is lower than all available
    if (desired_level < parseInt(available_levels[0].label)) {
    jwplayer().setCurrentQuality(0);
    }
    // check if desired level is higher than all available
    // Check if desired level is higher than all available
    else if(desired_level > parseInt(available_levels[available_levels.length - 1].label)) {
    jwplayer().setCurrentQuality(available_levels.length - 1);
    }
    // else find level that is next smallest
    // Else find level that is next smallest
    else {
    for (var i = 0; i < available_levels.length; i++) {
    if(desired_level < parseInt(available_levels[i].label)) {
    @@ -598,16 +596,15 @@ if (video_page.test(url)) {
    }
    }

    // pause the video if option is enabled
    // Pause the video if option is enabled
    if (pause_option) {
    jwplayer().pause();
    }

    // settup callback for end of video checks
    // Setup callback for end of video checks
    jwplayer().onComplete(check_for_end);

    });
    }
    };
    // Check for end of playback and move to next video
    var check_for_end = function () {
    var button = document.getElementById('btnNext');
    @@ -623,7 +620,7 @@ if (video_page.test(url)) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }
    };
    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    @@ -637,10 +634,10 @@ if (video_page.test(url)) {

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    // call injected function, hopefully after jwplayer has been settup
    // Call injected function, hopefully after jwplayer has been settup
    setTimeout(function() {
    unsafeWindow.flash_player_controls();
    },500);
    }, 500);

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    @@ -656,7 +653,7 @@ if (video_page.test(url)) {
    else {
    console.log('Using HTML5 Player');

    // move quality select below player
    // Move quality select below player
    var html_quality_select = document.getElementById('selectQuality');
    if (html_quality_select) {
    var video_area = document.getElementById('centerDivVideo');
    @@ -670,11 +667,11 @@ if (video_page.test(url)) {
    // Functions to inject on page for html5 video control
    var html5_video_options = function() {
    console.log("HTML5 Player custom Controls Initialized");
    // change the quality to desired flash option
    // Change the quality to desired flash option
    var available_levels = $('#selectQuality')[0];
    var level_set = false;
    var desired_level = parseInt(quality_option);
    // try to find exact quality level
    // Try to find exact quality level
    for (var i = 0; i < available_levels.length; i++) {
    if (desired_level == parseInt(available_levels.options[i].innerHTML)) {
    available_levels.selectedIndex = i;
    @@ -685,21 +682,21 @@ if (video_page.test(url)) {
    }
    }

    // try to find best level alternate
    // Try to find best level alternate
    if (!level_set) {
    // check if desired level is higher than all available
    if (desired_level < parseInt(available_levels.options[available_levels.length - 1].innerHTML)) {
    available_levels.selectedIndex = available_levels.length - 1;
    $('#selectQuality').change();
    $('.clsTempMSg').remove();
    }
    // check if desired level is lower than all available
    // Check if desired level is lower than all available
    else if (desired_level > parseInt(available_levels.options[0].innerHTML)) {
    available_levels.selectedIndex = 0;
    $('#selectQuality').change();
    $('.clsTempMSg').remove();
    }
    // else find level that is next smallest
    // Else find level that is next smallest
    else {
    for (var i = 0; i < available_levels.length; i++) {
    if (desired_level > parseInt(available_levels.options[i].innerHTML)) {
    @@ -711,8 +708,6 @@ if (video_page.test(url)) {
    }
    }



    if (pause_option) {
    my_video_1_html5_api.pause();
    }
    @@ -735,7 +730,7 @@ if (video_page.test(url)) {
    }
    }

    // injected speed controls
    // Injected speed controls
    var playback_decrease = function() {
    my_video_1_html5_api.playbackRate -= 0.25;
    }
    @@ -747,15 +742,15 @@ if (video_page.test(url)) {
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var html5_video_options = ' + html5_video_options.toString() + '\n' +
    'var html5_video_end = ' + html5_video_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = ' + quality_option.toString() + '\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    'var html5_video_end = ' + html5_video_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = ' + quality_option.toString() + '\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    // Call the injected script
    @@ -769,12 +764,12 @@ if (video_page.test(url)) {
    GM_setValue("auto_count", autoplay_count);
    });

    // remove extra (ghost) vjs-tip
    // Remove extra (ghost) vjs-tip
    setInterval(function() {
    $(document.querySelectorAll('#vjs-tip')).slice(1).remove();
    }, 500);

    // key listener
    // Key listener
    window.addEventListener('keydown', function(e) {
    if (e.code === 'NumpadMultiply' && $('#btnPrevious').length) { /* previous episode */
    console.log('Skipping to previous episode');
    @@ -870,7 +865,7 @@ if (video_page.test(url)) {

    if (resize_option) {
    window.addEventListener("resize", resize_video_area);
    // wait some for vid to get added to page, and initialy resize it
    // Wait some for vid to get added to page, and initialy resize it
    setTimeout(function() {
    resize_video_area();
    }, 1000);
    @@ -888,7 +883,7 @@ if (video_page.test(url)) {
    // Get which key is pressed
    var key_pressed = event.which;
    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    // Check to make sure video isnt playing
    if ((USE_FLASH_FOR_PAGE && YOUTUBE_FLASH_PLAYER && unsafeWindow.embedVideo.getPlayerState() == 2) || (USE_FLASH_FOR_PAGE && !YOUTUBE_FLASH_PLAYER && unsafeWindow.jwplayer().getState() == "PAUSED")
    || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)) {
    // Left arrow key to go to previous video
    @@ -901,7 +896,7 @@ if (video_page.test(url)) {
    // Prevent Default Action of scrolling
    event.preventDefault();
    }
    // right arrow key for next video
    // Right arrow key for next video
    else if (key_pressed == RIGHT_ARROW_KEY) {
    var button = document.getElementById('btnNext');
    if (button) {
    @@ -1005,7 +1000,7 @@ var global_key_listener = function(event) {
    event.preventDefault();
    open_menu();
    }
    }
    };
    var open_menu = function() {
    if (!menu_open) {
    menu_open = true;
    @@ -1014,25 +1009,25 @@ var open_menu = function() {
    menu.id = 'cleaner-options';
    menu.style.cssText = 'color:black;width:250px;height:320px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.innerHTML = '<center><b>KissAnime Cleaner Options</b></center>' +
    '<form><input style="margin:2px;" type="checkbox" name="pause" value="true" id="pause_option_box"> Pause Videos on Page Load <br>' +
    '<input style="margin:2px;" type="checkbox" name="autoplay" value="true" id="autoplay_option_box"> Automatically Play Next <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="autoplaycount" id="autoplay_count" min="-1" max="999"> Video(s) (choose -1 to play all)<br>' +
    '<input style="margin:2px;" type="checkbox" name="autoscroll" value="true" id="autoscroll_option_box"> Automatically Scroll Down to Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="resize" value="true" id="resize_option_box"> Resize Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="arrow_nav" value="true" id="arrow_nav_box"> Arrow Keys Navigate Between Videos <br>' +
    '<input style="margin:2px;" type="checkbox" name="speed_playback" value="true" id="playback_speed_control_box"> Enable HTML5 Playback speed controls <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_login" value="true" id="remove_login_box"> Disable Login <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_comments" value="true" id="remove_comments_box"> Disable Comments <br><br>' +
    '<center><b>Player Options</b></center>' +
    '<table style="width: 100%;border-collapse:separate;border-spacing:2px;"><tr><td><input style="margin:2px;" type="radio" name="player" value="flash" id="flash_option"> Flash Player</td>' +
    '<td align="right"><select style="margin:2px;" id="quality_select">' +
    '<option value="360">360p</option>' +
    '<option value="480">480p</option>' +
    '<option value="720">720p</option>' +
    '<option value="1080">1080p</option>' +
    '</select></td></tr>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td>' +
    '<td align="right">Volume <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="volumepercent" id="volume_percent" min="0" max="100"></td></tr></table>' +
    '<center><input style="margin:2px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;padding:2px 5px 2px 5px;width:44px;height:27px;line-height:3px;" type="button" value="Save" id="menu_sumbit_button"></center></form>';
    '<form><input style="margin:2px;" type="checkbox" name="pause" value="true" id="pause_option_box"> Pause Videos on Page Load <br>' +
    '<input style="margin:2px;" type="checkbox" name="autoplay" value="true" id="autoplay_option_box"> Automatically Play Next <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="autoplaycount" id="autoplay_count" min="-1" max="999"> Video(s) (choose -1 to play all)<br>' +
    '<input style="margin:2px;" type="checkbox" name="autoscroll" value="true" id="autoscroll_option_box"> Automatically Scroll Down to Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="resize" value="true" id="resize_option_box"> Resize Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="arrow_nav" value="true" id="arrow_nav_box"> Arrow Keys Navigate Between Videos <br>' +
    '<input style="margin:2px;" type="checkbox" name="speed_playback" value="true" id="playback_speed_control_box"> Enable HTML5 Playback speed controls <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_login" value="true" id="remove_login_box"> Disable Login <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_comments" value="true" id="remove_comments_box"> Disable Comments <br><br>' +
    '<center><b>Player Options</b></center>' +
    '<table style="width: 100%;border-collapse:separate;border-spacing:2px;"><tr><td><input style="margin:2px;" type="radio" name="player" value="flash" id="flash_option"> Flash Player</td>' +
    '<td align="right"><select style="margin:2px;" id="quality_select">' +
    '<option value="360">360p</option>' +
    '<option value="480">480p</option>' +
    '<option value="720">720p</option>' +
    '<option value="1080">1080p</option>' +
    '</select></td></tr>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td>' +
    '<td align="right">Volume <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="volumepercent" id="volume_percent" min="0" max="100"></td></tr></table>' +
    '<center><input style="margin:2px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;padding:2px 5px 2px 5px;width:44px;height:27px;line-height:3px;" type="button" value="Save" id="menu_sumbit_button"></center></form>';

    // Add menu to page
    document.getElementById('containerRoot').appendChild(menu);
    @@ -1108,80 +1103,80 @@ var open_menu = function() {
    } else {
    menu_save();
    }
    }
    };

    var menu_save = function() {
    // Get all of the form choices for checking
    var pause_option_box = document.getElementById('pause_option_box');
    var autoplay_option_box = document.getElementById('autoplay_option_box');
    var autoplay_count_input = document.getElementById('autoplay_count');
    var autoscroll_option_box = document.getElementById('autoscroll_option_box');
    var resize_option_box = document.getElementById('resize_option_box');
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');
    var remove_login_box = document.getElementById('remove_login_box');
    var remove_comments_box = document.getElementById('remove_comments_box');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    GM_setValue("auto", autoplay_option_box.checked);
    GM_setValue("scroll", autoscroll_option_box.checked);
    GM_setValue("auto_count", parseInt(autoplay_count_input.value));
    GM_setValue("resize", resize_option_box.checked);
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);
    GM_setValue("remove_login", remove_login_box.checked);
    GM_setValue("remove_comments", remove_comments_box.checked);

    // Check which player option is checked
    if (flash_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_FLASH;
    } else if (html5_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_HTML5;
    // Get all of the form choices for checking
    var pause_option_box = document.getElementById('pause_option_box');
    var autoplay_option_box = document.getElementById('autoplay_option_box');
    var autoplay_count_input = document.getElementById('autoplay_count');
    var autoscroll_option_box = document.getElementById('autoscroll_option_box');
    var resize_option_box = document.getElementById('resize_option_box');
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');
    var remove_login_box = document.getElementById('remove_login_box');
    var remove_comments_box = document.getElementById('remove_comments_box');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    GM_setValue("auto", autoplay_option_box.checked);
    GM_setValue("scroll", autoscroll_option_box.checked);
    GM_setValue("auto_count", parseInt(autoplay_count_input.value));
    GM_setValue("resize", resize_option_box.checked);
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);
    GM_setValue("remove_login", remove_login_box.checked);
    GM_setValue("remove_comments", remove_comments_box.checked);

    // Check which player option is checked
    if (flash_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    }

    // Update this pages userscript options
    pause_option = pause_option_box.checked;
    autoplay_option = autoplay_option_box.checked;
    autoscroll_option = autoscroll_option_box.checked;
    arrow_key_navagation = arrow_nav_box.checked;
    autoplay_count = parseInt(autoplay_count_input.value);
    quality_option = quality_select.value;
    speed_control = playback_speed_control_box.checked;

    // Update unsafeWindow values that might matter if on video pages
    if (video_page.test(url)) {
    unsafeWindow.autoplay_option = autoplay_option_box.checked;
    unsafeWindow.autoplay_count = parseInt(autoplay_count_input.value);
    player_option = PLAYER_FLASH;
    } else if (html5_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_HTML5;
    }

    menu.remove();
    menu_open = false;
    // Update this pages userscript options
    pause_option = pause_option_box.checked;
    autoplay_option = autoplay_option_box.checked;
    autoscroll_option = autoscroll_option_box.checked;
    arrow_key_navagation = arrow_nav_box.checked;
    autoplay_count = parseInt(autoplay_count_input.value);
    quality_option = quality_select.value;
    speed_control = playback_speed_control_box.checked;

    // Update unsafeWindow values that might matter if on video pages
    if (video_page.test(url)) {
    unsafeWindow.autoplay_option = autoplay_option_box.checked;
    unsafeWindow.autoplay_count = parseInt(autoplay_count_input.value);
    }

    menu.remove();
    menu_open = false;
    };
    // Add the listener for keypresses
    document.addEventListener("keydown", global_key_listener);
    // Also add as GM menu command
    @@ -1193,7 +1188,7 @@ var search_results = document.getElementById('result_box');
    var search_form = document.getElementById('keyword');
    // Current search selection, -1 if nothing
    var search_selection = -1;
    // used to scroll search results to current highlighted results
    // Used to scroll search results to current highlighted results
    var scroll_height = 0;
    // Interval for checking if any results match and appear
    var navigation_interval;
    @@ -1205,12 +1200,12 @@ var DOWN_ARROW_KEY = 40;
    var ENTER_KEY = 13;
    // Prevent up and down arrow keys from causing the results to refresh
    var prevent_key_reg = function(event) {
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY || key_pressed == DOWN_ARROW_KEY) {
    event.stopPropagation();
    }
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY || key_pressed == DOWN_ARROW_KEY) {
    event.stopPropagation();
    }
    // Add above in the capture phase of event propagation, so it happens first
    };
    // Add above in the capture phase of event propagation, so it happens first
    document.addEventListener('keyup', prevent_key_reg, true);
    // Intercept Enter key press to check if anything is selected
    var go_to_selection = function(event) {
    @@ -1224,56 +1219,55 @@ var go_to_selection = function(event) {
    event.preventDefault();
    }
    }
    }
    };
    document.addEventListener('keydown', go_to_selection);
    // Navigate up and down in search results
    var navigate_search_results = function(event) {
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY) {
    if (search_selection > 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    search_results.children[--search_selection].style.backgroundColor = '#565E66';

    scroll_height -= search_results.children[search_selection + 1].clientHeight;
    if (search_selection == 0) {
    scroll_height = 0;
    }
    search_results.scrollTop = scroll_height;
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY) {
    if (search_selection > 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    search_results.children[--search_selection].style.backgroundColor = '#565E66';

    scroll_height -= search_results.children[search_selection + 1].clientHeight;
    if (search_selection == 0) {
    scroll_height = 0;
    }
    search_results.scrollTop = scroll_height;
    }
    if (key_pressed == DOWN_ARROW_KEY) {
    if (search_selection < search_results.childElementCount - 1) {
    if (search_selection >= 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    }
    search_results.children[++search_selection].style.backgroundColor = '#565E66';
    scroll_height += search_results.children[search_selection - 1].clientHeight;
    search_results.scrollTop = scroll_height;
    }
    if (key_pressed == DOWN_ARROW_KEY) {
    if (search_selection < search_results.childElementCount - 1) {
    if (search_selection >= 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    }
    search_results.children[++search_selection].style.backgroundColor = '#565E66';
    scroll_height += search_results.children[search_selection - 1].clientHeight;
    search_results.scrollTop = scroll_height;
    }
    }
    // Checks if there are navigatable results and adds navigate listener
    };
    // Checks if there are navigatable results and adds navigate listener
    var reset_navigation = function() {
    search_selection = -1;
    scroll_height = 0;
    ++navigation_attempts;
    if (search_results.childElementCount > 0) {
    document.addEventListener('keydown', navigate_search_results);
    search_selection = -1;
    scroll_height = 0;
    ++navigation_attempts;
    if (search_results.childElementCount > 0) {
    document.addEventListener('keydown', navigate_search_results);
    clearInterval(navigation_interval);
    } else {
    document.removeEventListener('keydown', navigate_search_results);
    if (navigation_attempts >= 10) {
    clearInterval(navigation_interval);
    } else {
    document.removeEventListener('keydown', navigate_search_results);
    if (navigation_attempts >= 10) {
    clearInterval(navigation_interval);
    }
    }

    }
    // Called everytime search text box input changes to see if there is navigatable results
    };
    // Called everytime search text box input changes to see if there is navigatable results
    var try_navigation = function() {
    clearInterval(navigation_interval);
    navigation_attempts = 0;
    navigation_interval = setInterval(reset_navigation, 200);
    }
    };
    search_form.addEventListener('input', try_navigation);

    console.log('Done!');
  6. Juici revised this gist Sep 2, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,5 @@ Install
    -------
    * Get [Greasemonkey for FireFox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) if you don't already have it.
    * Click this link [KissAnime Cleaner](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js), wait 5 seconds, and click install to add the script.

    Installing with this link should retain any settings from the original KissAnime Cleaner by crapier, however I cannot gaurantee it (so don't cry if you have to spend a minute redoing your settings :P)

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
  7. Juici revised this gist Sep 2, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,7 @@ Install
    -------
    * Get [Greasemonkey for FireFox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) if you don't already have it.
    * Click this link [KissAnime Cleaner](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js), wait 5 seconds, and click install to add the script.

    Installing with this link should retain any settings from the original KissAnime Cleaner by crapier, however I cannot gaurantee it (so don't cry if you have to spend a minute redoing your settings :P)

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
  8. Juici revised this gist Sep 2, 2016. 1 changed file with 11 additions and 4 deletions.
    15 changes: 11 additions & 4 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -10,26 +10,33 @@ Features
    * Use up and down arrow keys to navigate suggested search results box on all pages (top right)
    * Fake fullscreen mode toggle with \ key
    * Maintained across page loads, if you make your browser fullscreen with F11 it will look like real fullscreen. Seek bar is hidden in HTML5 player when in fake fullscreen.
    * Configurable Options (Press **Home key on keyboard** or the option in the **User Script Commands menu** for KissAnime Cleaner menu)
    * Configurable Options (Press **Home key on keyboard** or the option in the **User Script Commands menu** for KissAnime Cleaner menu) (Added an id to the element to allow for easier userstyling)
    * Pause the video on page load
    * Automatically advance to the next video when the current one finishes
    * Option to chooses how many videos to play (-1 for continuous playback)
    * Automatically scroll down some on video pages
    * Resize Video Area to keep it centered and visible in smaller windows
    * Use the arrow keys to go to the previous or next video (only when video is paused)
    * Resize video area to keep it centered and visible in smaller windows
    * Use the left/right arrow keys to go to the previous or next video (only when video is paused)
    * Use the - and = keys to increase and decrease the playback speed for HTML5 player (flash player does not provide support)
    * Player option (flash, html5) moved to KissAnime Clear menu (home key on keyboard)
    * Select preferred quality (should now work for both flash and html5)
    * Will attempt to set quality of video to selected value or next lowest value if selected is not available
    * Set Player Volume
    * Use Numpad * and - keys to go to previous or next video (I prefer this to the arrow key version)
    * Hold Ctrl key when pressing left/right arrow keys to skip 20s back/forward

    The script also works on KissCartoon and KissAsian.


    Usage
    -----
    Only tested in FireFox with Greasemonkey (should work with Tapermonkey and Chrome).


    Install
    -------
    * Get [Greasemonkey for FireFox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) if you don't already have it.
    * Click on the [raw link](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js) for **kissanime_cleaner.user.js** below, wait 5 seconds, and click install to add the script.
    * Click this link [KissAnime Cleaner](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js), wait 5 seconds, and click install to add the script.
    Installing with this link should retain any settings from the original KissAnime Cleaner by crapier, however I cannot gaurantee it (so don't cry if you have to spend a minute redoing your settings :P)

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
  9. Juici revised this gist Sep 2, 2016. 2 changed files with 36 additions and 4 deletions.
    6 changes: 3 additions & 3 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    KissAnime Cleaner
    =================

    This userscript for KissAnime was made for my personal use to remove large chunks of the site that I do not use, including any options to login or use features only for members. Along the way I ended up adding some other small features listed below.
    This userscript for KissAnime is a fork of the [original by crapier](https://gist.github.com/crapier/91926a6353207f4524cc). It removes large chunks of the site that I do not use, including any options to login or use features only for members. I will be updating this fork as the original is updated applying fixes where neccessary and minor tweaks of my own.

    Features
    --------
    @@ -29,7 +29,7 @@ The script also works on KissCartoon and KissAsian.
    Usage
    -----
    Only tested in FireFox with Greasemonkey (should work with Tapermonkey and Chrome).
    * Get Greasemonkey for FireFox if you don't already have it. [link](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/)
    * Click on the Raw link for **kissanime_cleaner.user.js** below, wait 5 seconds, and click install to add the script.
    * Get [Greasemonkey for FireFox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) if you don't already have it.
    * Click on the [raw link](https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js) for **kissanime_cleaner.user.js** below, wait 5 seconds, and click install to add the script.

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
    34 changes: 33 additions & 1 deletion kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.16
    // @version 3.3.15.1
    // @downloadURL https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -312,6 +312,9 @@ if (anime_page.test(url)) {
    clearInterval(adremover);
    }
    }, 100);

    // Remove space before episodes
    $('table.listing').css('margin-top', '-18px');

    console.log('Done!');
    }
    @@ -765,6 +768,34 @@ if (video_page.test(url)) {
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });

    // remove extra (ghost) vjs-tip
    setInterval(function() {
    $(document.querySelectorAll('#vjs-tip')).slice(1).remove();
    }, 500);

    // key listener
    window.addEventListener('keydown', function(e) {
    if (e.code === 'NumpadMultiply' && $('#btnPrevious').length) { /* previous episode */
    console.log('Skipping to previous episode');
    $('#btnPrevious').click();
    e.preventDefault();
    } else if (e.code === 'NumpadSubtract' && $('#btnNext').length) { /* next episode */
    console.log('Skipping to next episode');
    $('#btnNext').click();
    e.preventDefault();
    }

    if (e.ctrlKey) { /* ctrl key for 20s skip */
    if (e.code === 'ArrowLeft') { /* back 20s */
    my_video_1_html5_api.currentTime -= 20;
    e.preventDefault();
    } else if (e.code === 'ArrowRight') { /* forward 20s */
    my_video_1_html5_api.currentTime += 20;
    e.preventDefault();
    }
    }
    });
    }

    // Scroll to the Container
    @@ -980,6 +1011,7 @@ var open_menu = function() {
    menu_open = true;
    // Make div element for menu
    menu = document.createElement('div');
    menu.id = 'cleaner-options';
    menu.style.cssText = 'color:black;width:250px;height:320px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.innerHTML = '<center><b>KissAnime Cleaner Options</b></center>' +
    '<form><input style="margin:2px;" type="checkbox" name="pause" value="true" id="pause_option_box"> Pause Videos on Page Load <br>' +
  10. Juici revised this gist Sep 1, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.15
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @version 3.3.16
    // @downloadURL https://gist.github.com/Juici/4f9ce7f72790337567b4c93f76589b79/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    // @grant GM_registerMenuCommand
    @@ -389,7 +389,7 @@ if (video_page.test(url)) {
    vid_parent.removeChild(vid_parent.children[i--]);
    }
    }
    vid_parent.children[3].remove();
    vid_parent.children[1].remove();

    if (remove_comments) {
    // Get the comment section on the video pages
  11. @crapier crapier revised this gist Jul 21, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.14
    // @version 3.3.15
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -46,7 +46,7 @@ var fake_fullscreen = GM_getValue("fake_fullscreen", false);
    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var home = /http:\/\/kissanime\.to\/$|https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|https:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$|https:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|https:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)|https:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*$|https:\/\/kissanime\.to\/Anime\/[^\/]*$|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|http:\/\/kissasian\.com\/Drama\/[^\/]*$|https:\/\/kissasian\.com\/Drama\/[^\/]*$/;
    var video_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*/;
  12. @crapier crapier revised this gist Jul 21, 2016. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,12 @@
    // @namespace 9001
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include https://kissanime.to/*
    // @include http://kissanime.to/*
    // @include https://kisscartoon.me/*
    // @include http://kisscartoon.me/*
    // @include https://kissasian.com/*
    // @include http://kissasian.com/*
    // @version 3.3.13
    // @version 3.3.14
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -44,9 +47,9 @@ var fake_fullscreen = GM_getValue("fake_fullscreen", false);
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /https:\/\/kissanime\.to\/Anime\/[^\/]*$|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|http:\/\/kissasian\.com\/Drama\/[^\/]*$/;
    var video_page = /https:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*/;
    var anime_list = /http:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|https:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)|https:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*$|https:\/\/kissanime\.to\/Anime\/[^\/]*$|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|http:\/\/kissasian\.com\/Drama\/[^\/]*$|https:\/\/kissasian\.com\/Drama\/[^\/]*$/;
    var video_page = /http:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*|https:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
  13. @crapier crapier revised this gist Feb 26, 2016. 2 changed files with 70 additions and 23 deletions.
    2 changes: 2 additions & 0 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@ Features
    * Removes any link, tabs, buttons, pages, etc. that I will never use.
    * Also removes ads on any pages that still remain
    * Use up and down arrow keys to navigate suggested search results box on all pages (top right)
    * Fake fullscreen mode toggle with \ key
    * Maintained across page loads, if you make your browser fullscreen with F11 it will look like real fullscreen. Seek bar is hidden in HTML5 player when in fake fullscreen.
    * Configurable Options (Press **Home key on keyboard** or the option in the **User Script Commands menu** for KissAnime Cleaner menu)
    * Pause the video on page load
    * Automatically advance to the next video when the current one finishes
    91 changes: 68 additions & 23 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include https://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.12
    // @version 3.3.13
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -38,6 +38,7 @@ var speed_control = GM_getValue("speed_control", true);
    var volume_control = GM_getValue("volume_control", 100);
    var remove_login = GM_getValue("remove_login", true);
    var remove_comments = GM_getValue("remove_comments", true);
    var fake_fullscreen = GM_getValue("fake_fullscreen", false);

    // Current page url
    var url = document.location.href;
    @@ -711,7 +712,6 @@ if (video_page.test(url)) {
    }
    my_video_1_html5_api.volume = volume_control / 100;
    my_video_1_html5_api.addEventListener('ended', html5_video_end);
    setTimeout('my_video_1_html5_api.focus();', 0);
    }
    var html5_video_end = function() {
    var button = document.getElementById('btnNext');
    @@ -769,29 +769,68 @@ if (video_page.test(url)) {
    document.getElementById('container').scrollIntoView(true);
    }


    var resize_video_area = function() {
    var resize_to = window.innerWidth - 30;
    if (resize_to > 970) {
    resize_to = 970;
    if (fake_fullscreen) {
    var resize_width = window.innerWidth;
    var resize_height = window.innerHeight;

    document.getElementById('container').style.width = "" + (resize_width) + "px";
    document.getElementById('adsIfrme').style.width = "" + (resize_width) + "px";
    $(".barContent")[0].children[0].style.width = "" + (resize_width) + "px";

    document.getElementById('centerDivVideo').style.width = "" + (resize_width) + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_height) + "px";

    if (USE_FLASH_FOR_PAGE) {
    document.getElementById('divContentVideo').style.width = "" + (resize_width) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_height) + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_width) + "px";
    document.getElementById('embedVideo').style.height = "" + (resize_height) + "px";
    } else {
    document.getElementById('divContentVideo').style.width = "" + (resize_width) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_height) + "px";
    document.getElementById('my_video_1').style.width = "" + (resize_width) + "px";
    document.getElementById('my_video_1').style.height = "" + (resize_height) + "px";
    }

    var seek_bar = $('.vjs-control-bar');
    if (seek_bar.length > 0) {
    seek_bar[0].style.visibility = 'hidden';
    }

    document.getElementById('centerDivVideo').scrollIntoView(true);
    document.body.style.overflow = 'hidden';
    }
    document.getElementById('container').style.width = "" + (resize_to) + "px";
    document.getElementById('adsIfrme').style.width = "" + (resize_to - 20) + "px";
    $(".barContent")[0].children[0].style.width = "" + (resize_to - 40) + "px";

    document.getElementById('centerDivVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";

    if (USE_FLASH_FOR_PAGE) {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('embedVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    } else {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('my_video_1').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('my_video_1').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    else {
    var resize_to = window.innerWidth - 30;
    if (resize_to > 970) {
    resize_to = 970;
    }
    document.getElementById('container').style.width = "" + (resize_to) + "px";
    document.getElementById('adsIfrme').style.width = "" + (resize_to - 20) + "px";
    $(".barContent")[0].children[0].style.width = "" + (resize_to - 40) + "px";

    document.getElementById('centerDivVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";

    if (USE_FLASH_FOR_PAGE) {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('embedVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    } else {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('my_video_1').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('my_video_1').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    }

    var seek_bar = $('.vjs-control-bar');
    if (seek_bar.length > 0) {
    seek_bar[0].style.visibility = 'visible';
    }
    document.body.style.overflow = 'visible';
    }
    }

    @@ -810,6 +849,7 @@ if (video_page.test(url)) {
    var RIGHT_ARROW_KEY = 39;
    var MINUS_DASH_KEY = 173;
    var PLUS_EQUALS_KEY = 61;
    var BAR_FORWARD_SLASH_KEY = 220;
    var key_listener = function(event) {
    // Get which key is pressed
    var key_pressed = event.which;
    @@ -848,6 +888,11 @@ if (video_page.test(url)) {
    unsafeWindow.playback_increase();
    }
    }
    if (key_pressed == BAR_FORWARD_SLASH_KEY) {
    fake_fullscreen = !fake_fullscreen;
    GM_setValue('fake_fullscreen', fake_fullscreen);
    resize_video_area();
    }
    }
    // Add the listener for keypresses
    document.addEventListener("keydown", key_listener);
  14. @crapier crapier revised this gist Feb 19, 2016. 1 changed file with 62 additions and 24 deletions.
    86 changes: 62 additions & 24 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include https://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.11
    // @version 3.3.12
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -44,8 +44,8 @@ var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /https:\/\/kissanime\.to\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /https:\/\/kissanime\.to\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;
    var anime_page = /https:\/\/kissanime\.to\/Anime\/[^\/]*$|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*$|http:\/\/kissasian\.com\/Drama\/[^\/]*$/;
    var video_page = /https:\/\/kissanime\.to\/Anime\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[^\/]*\/[^\/]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[^\/]*\/[^\/]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
    @@ -109,18 +109,28 @@ if (home.test(url)) {
    adspace1.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    // Remove or hide stubborn ads
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    var body = document.body;
    if (body.childElementCount > 1) {
    var inital_count = body.childElementCount;
    for (var i = inital_count - 1; i > 0 ; i--) {
    body.children[i].remove();
    }
    }
    var container = document.getElementById('containerRoot');
    var total_elements = container.childElementCount;
    for (var i = total_elements - 1; container.children[i].id != 'container' ; i--) {
    container.children[i].style.visibility = 'hidden';
    container.children[i].style.height = '0px';
    container.children[i].style.width = '0px';
    }

    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }, 100);

    console.log('Done!');
    @@ -165,18 +175,28 @@ if (anime_list.test(url)) {
    adspace2.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    // Remove or hide stubborn ads
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    var body = document.body;
    if (body.childElementCount > 1) {
    var inital_count = body.childElementCount;
    for (var i = inital_count - 1; i > 0 ; i--) {
    body.children[i].remove();
    }
    }
    var container = document.getElementById('containerRoot');
    var total_elements = container.childElementCount;
    for (var i = total_elements - 1; container.children[i].id != 'container' ; i--) {
    container.children[i].style.visibility = 'hidden';
    container.children[i].style.height = '0px';
    container.children[i].style.width = '0px';
    }

    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }, 100);

    console.log('Done!');
    @@ -257,18 +277,36 @@ if (anime_page.test(url)) {
    bookmark_link.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    // Remove or hide stubborn ads
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    var body = document.body;
    if (body.childElementCount > 1) {
    var inital_count = body.childElementCount;
    for (var i = inital_count - 1; i > 0 ; i--) {
    body.children[i].remove();
    }
    }
    var container = document.getElementById('containerRoot');
    var total_elements = container.childElementCount;
    for (var i = total_elements - 1; container.children[i].id != 'container' ; i--) {
    container.children[i].style.visibility = 'hidden';
    container.children[i].style.height = '0px';
    container.children[i].style.width = '0px';
    }

    var rightside = document.getElementById('rightside');
    total_elements = rightside.childElementCount;
    for (var i = total_elements - 1; rightside.children[i].className != 'rightBox' ; i--) {
    rightside.children[i].style.visibility = 'hidden';
    rightside.children[i].style.height = '0px';
    rightside.children[i].style.width = '0px';
    }

    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }, 100);

    console.log('Done!');
  15. @crapier crapier revised this gist Jan 12, 2016. 1 changed file with 16 additions and 42 deletions.
    58 changes: 16 additions & 42 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include https://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.10
    // @version 3.3.11
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -390,56 +390,40 @@ if (video_page.test(url)) {
    var USE_FLASH_FOR_PAGE;
    var YOUTUBE_FLASH_PLAYER;
    if (player_option == PLAYER_FLASH) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingFlashV1') < 0) {
    if (document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if (/kissasian/.test(url) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // check if page actually has youtube info
    if (unsafeWindow.txha) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = true;
    } else if (unsafeWindow.jwplayer) {
    if (unsafeWindow.jwplayer) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = false;
    } else {
    } else if (unsafeWindow.myPlayer) {
    USE_FLASH_FOR_PAGE = false;
    YOUTUBE_FLASH_PLAYER = false;
    } else {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = true;
    }
    } else {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingHTML5V1') < 0) {
    if (document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if (/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // check that page actually has html5 player
    if (unsafeWindow.myPlayer) {
    USE_FLASH_FOR_PAGE = false;
    YOUTUBE_FLASH_PLAYER = false;
    } else if (unsafeWindow.txha) {
    } else if (unsafeWindow.jwplayer) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = true;
    YOUTUBE_FLASH_PLAYER = false;
    } else {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = false;
    YOUTUBE_FLASH_PLAYER = true;
    }
    }

    @@ -778,7 +762,7 @@ if (video_page.test(url)) {
    // wait some for vid to get added to page, and initialy resize it
    setTimeout(function() {
    resize_video_area();
    }, 800);
    }, 1000);
    }


    @@ -1042,13 +1026,8 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    } else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    @@ -1058,13 +1037,8 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    } else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    }
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
  16. @crapier crapier revised this gist Nov 30, 2015. 1 changed file with 28 additions and 25 deletions.
    53 changes: 28 additions & 25 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include https://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.9
    // @version 3.3.10
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -110,15 +110,16 @@ if (home.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }
    }, 100);

    @@ -165,15 +166,16 @@ if (anime_list.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }
    }, 100);

    @@ -256,15 +258,16 @@ if (anime_page.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adcheck_count = 0;
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    adcheck_count++;
    var body = document.getElementById('containerRoot').parentElement;
    if (body.childElementCount >= 5) {
    body.children[body.childElementCount - 1].remove();
    body.children[body.childElementCount - 1].remove();
    if (adcheck_count == 50) {
    clearInterval(adremover);
    }
    }
    }, 100);

  17. @crapier crapier revised this gist Nov 22, 2015. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@
    // @name KissAnime Cleaner
    // @namespace 9001
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.to/*
    // @include https://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.8
    // @version 3.3.9
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -42,10 +42,10 @@ var remove_comments = GM_getValue("remove_comments", true);
    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /http:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.to\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /http:\/\/kissanime\.to\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;
    var home = /https:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /https:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /https:\/\/kissanime\.to\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /https:\/\/kissanime\.to\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
  18. @crapier crapier revised this gist Nov 5, 2015. 1 changed file with 60 additions and 35 deletions.
    95 changes: 60 additions & 35 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,10 @@
    // @name KissAnime Cleaner
    // @namespace 9001
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.com/*
    // @include http://kissanime.to/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.7
    // @version 3.3.8
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -36,14 +36,16 @@ var resize_option = GM_getValue("resize", true);
    var arrow_key_navagation = GM_getValue("arrow_nav", true);
    var speed_control = GM_getValue("speed_control", true);
    var volume_control = GM_getValue("volume_control", 100);
    var remove_login = GM_getValue("remove_login", true);
    var remove_comments = GM_getValue("remove_comments", true);

    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /http:\/\/kissanime\.com\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.com\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;
    var home = /http:\/\/kissanime\.to\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.to\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.to\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /http:\/\/kissanime\.to\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
    @@ -236,14 +238,16 @@ if (anime_page.test(url)) {
    }
    }

    // Remove comments
    var comment_location = 2;
    if (/kissasian/.test(url)) {
    comment_location = 3;
    }
    var comments = $('div.bigBarContainer')[comment_location];
    if (comments) {
    comments.remove();
    if (remove_comments) {
    // Remove comments
    var comment_location = 2;
    if (/kissasian/.test(url)) {
    comment_location = 3;
    }
    var comments = $('div.bigBarContainer')[comment_location];
    if (comments) {
    comments.remove();
    }
    }

    var bookmark_link = document.getElementById('spanBookmark');
    @@ -342,23 +346,26 @@ if (video_page.test(url)) {
    }
    vid_parent.children[3].remove();

    // Get the comment section on the video pages
    var comments = document.getElementById('btnShowComments');
    // If it exist remove it and the element just prior to it also, share stuff of some kind
    if (comments) {
    comments = comments.parentElement;
    comments.previousElementSibling.remove();
    comments.previousElementSibling.remove();
    comments.previousElementSibling.remove();
    comments.remove();
    }
    if (remove_comments) {
    // Get the comment section on the video pages
    var comments = document.getElementById('btnShowComments');
    // If it exist remove it and the element just prior to it also, share stuff of some kind
    if (comments) {
    comments = comments.parentElement;
    comments.previousElementSibling.remove();
    comments.previousElementSibling.remove();
    comments.previousElementSibling.remove();
    comments.remove();
    }


    // remove comments for kisscartoon site
    var alt_comments = document.getElementById('divComments');
    if (alt_comments) {
    alt_comments.previousElementSibling.remove();
    alt_comments.previousElementSibling.remove();
    alt_comments.remove();
    // remove comments for kisscartoon site
    var alt_comments = document.getElementById('divComments');
    if (alt_comments) {
    alt_comments.previousElementSibling.remove();
    alt_comments.previousElementSibling.remove();
    alt_comments.remove();
    }
    }

    // Hide on page quality selector, conflicts with custom menu selector
    @@ -837,9 +844,11 @@ if (search) {
    }

    // Remove Login at the top of the page
    var login = document.getElementById('topHolderBox');
    if (login) {
    login.remove();
    if (remove_login) {
    var login = document.getElementById('topHolderBox');
    if (login) {
    login.remove();
    }
    }

    // Remove Tabs I don't Use
    @@ -898,14 +907,16 @@ var open_menu = function() {
    menu_open = true;
    // Make div element for menu
    menu = document.createElement('div');
    menu.style.cssText = 'color:black;width:250px;height:270px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.style.cssText = 'color:black;width:250px;height:320px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.innerHTML = '<center><b>KissAnime Cleaner Options</b></center>' +
    '<form><input style="margin:2px;" type="checkbox" name="pause" value="true" id="pause_option_box"> Pause Videos on Page Load <br>' +
    '<input style="margin:2px;" type="checkbox" name="autoplay" value="true" id="autoplay_option_box"> Automatically Play Next <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="autoplaycount" id="autoplay_count" min="-1" max="999"> Video(s) (choose -1 to play all)<br>' +
    '<input style="margin:2px;" type="checkbox" name="autoscroll" value="true" id="autoscroll_option_box"> Automatically Scroll Down to Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="resize" value="true" id="resize_option_box"> Resize Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="arrow_nav" value="true" id="arrow_nav_box"> Arrow Keys Navigate Between Videos <br>' +
    '<input style="margin:2px;" type="checkbox" name="speed_playback" value="true" id="playback_speed_control_box"> Enable HTML5 Playback speed controls <br><br>' +
    '<input style="margin:2px;" type="checkbox" name="speed_playback" value="true" id="playback_speed_control_box"> Enable HTML5 Playback speed controls <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_login" value="true" id="remove_login_box"> Disable Login <br>' +
    '<input style="margin:2px;" type="checkbox" name="remove_comments" value="true" id="remove_comments_box"> Disable Comments <br><br>' +
    '<center><b>Player Options</b></center>' +
    '<table style="width: 100%;border-collapse:separate;border-spacing:2px;"><tr><td><input style="margin:2px;" type="radio" name="player" value="flash" id="flash_option"> Flash Player</td>' +
    '<td align="right"><select style="margin:2px;" id="quality_select">' +
    @@ -953,6 +964,16 @@ var open_menu = function() {
    playback_speed_control_box.checked = true;
    }

    var remove_login_box = document.getElementById('remove_login_box');
    if (remove_login) {
    remove_login_box.checked = true;
    }

    var remove_comments_box = document.getElementById('remove_comments_box');
    if (remove_comments) {
    remove_comments_box.checked = true;
    }

    // Player radios
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    @@ -997,6 +1018,8 @@ var menu_save = function() {
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');
    var remove_login_box = document.getElementById('remove_login_box');
    var remove_comments_box = document.getElementById('remove_comments_box');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    @@ -1008,6 +1031,8 @@ var menu_save = function() {
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);
    GM_setValue("remove_login", remove_login_box.checked);
    GM_setValue("remove_comments", remove_comments_box.checked);

    // Check which player option is checked
    if (flash_option.checked) {
  19. @crapier crapier revised this gist Nov 1, 2015. 1 changed file with 173 additions and 62 deletions.
    235 changes: 173 additions & 62 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.6
    // @version 3.3.7
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -378,6 +378,7 @@ if (video_page.test(url)) {


    var USE_FLASH_FOR_PAGE;
    var YOUTUBE_FLASH_PLAYER;
    if (player_option == PLAYER_FLASH) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingFlashV1') < 0) {
    @@ -396,8 +397,13 @@ if (video_page.test(url)) {
    // check if page actually has youtube info
    if (unsafeWindow.txha) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = true;
    } else if (unsafeWindow.jwplayer) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = false;
    } else {
    USE_FLASH_FOR_PAGE = false;
    YOUTUBE_FLASH_PLAYER = false;
    }
    } else {
    // bookmarks for kissanime
    @@ -417,54 +423,156 @@ if (video_page.test(url)) {
    // check that page actually has html5 player
    if (unsafeWindow.myPlayer) {
    USE_FLASH_FOR_PAGE = false;
    YOUTUBE_FLASH_PLAYER = false;
    } else if (unsafeWindow.txha) {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = true;
    } else {
    USE_FLASH_FOR_PAGE = true;
    YOUTUBE_FLASH_PLAYER = false;
    }
    }

    // Flash Player
    if (USE_FLASH_FOR_PAGE) {
    console.log('Using Flash Player');
    if (YOUTUBE_FLASH_PLAYER) {
    console.log('Using YouTube Player');

    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var onYouTubePlayerReady = function(playerId) {
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // translate option into youtubes quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    } else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    } else if (quality_option == '480') {
    youtube_quality_option = 'large';
    } else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var onYouTubePlayerReady = function(playerId) {
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // translate option into youtubes quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    } else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    } else if (quality_option == '480') {
    youtube_quality_option = 'large';
    } else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // set the volume
    embedVideo.setVolume(volume_control);
    // set the volume
    embedVideo.setVolume(volume_control);

    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);
    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function() {
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important") + 30);
    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function() {
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important") + 30);
    }
    }, 100);
    }
    // Check for end of playback and move to next video
    var check_for_end = function(state) {
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }
    }
    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var onYouTubePlayerReady = ' + onYouTubePlayerReady.toString() + '\n' +
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });
    }
    else {
    console.log('Using jwplayer.');
    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var flash_player_controls = function () {
    // wait till video is loaded into player
    jwplayer().onReady(function() {
    console.log("jwplayer custom Controls Initialized");
    // change the quality to desired flash option
    var available_levels = jwplayer().getQualityLevels();
    var level_set = false;
    var desired_level = parseInt(quality_option);

    // try to find exact quality level
    for (var i = 0; i < available_levels.length; i++) {
    if (desired_level == parseInt(available_levels[i].label)) {
    jwplayer().setCurrentQuality(i);
    level_set = true;
    break;
    }
    }

    // try to find best level alternate
    if (!level_set) {
    // check if desired level is lower than all available
    if (desired_level < parseInt(available_levels[0].label)) {
    jwplayer().setCurrentQuality(0);
    }
    // check if desired level is higher than all available
    else if(desired_level > parseInt(available_levels[available_levels.length - 1].label)) {
    jwplayer().setCurrentQuality(available_levels.length - 1);
    }
    // else find level that is next smallest
    else {
    for (var i = 0; i < available_levels.length; i++) {
    if(desired_level < parseInt(available_levels[i].label)) {
    jwplayer().setCurrentQuality(i-1);
    break;
    }
    }
    }
    }

    // pause the video if option is enabled
    if (pause_option) {
    jwplayer().pause();
    }
    }, 100);

    // settup callback for end of video checks
    jwplayer().onComplete(check_for_end);

    });
    }
    // Check for end of playback and move to next video
    var check_for_end = function(state) {
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    var check_for_end = function () {
    var button = document.getElementById('btnNext');
    if (button && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    @@ -473,35 +581,37 @@ if (video_page.test(url)) {
    }
    document.dispatchEvent(update_userscript);
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }
    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var onYouTubePlayerReady = ' + onYouTubePlayerReady.toString() + '\n' +
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var flash_player_controls = ' + flash_player_controls.toString() + '\n' +
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    // call injected function, hopefully after jwplayer has been settup
    setTimeout(function() {
    unsafeWindow.flash_player_controls();
    },500);

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });
    }

    }
    // HTML5 Player
    else {
    @@ -673,7 +783,8 @@ if (video_page.test(url)) {
    var key_pressed = event.which;
    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    if ((USE_FLASH_FOR_PAGE && unsafeWindow.embedVideo.getPlayerState() == 2) || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)) {
    if ((USE_FLASH_FOR_PAGE && YOUTUBE_FLASH_PLAYER && unsafeWindow.embedVideo.getPlayerState() == 2) || (USE_FLASH_FOR_PAGE && !YOUTUBE_FLASH_PLAYER && unsafeWindow.jwplayer().getState() == "PAUSED")
    || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)) {
    // Left arrow key to go to previous video
    if (key_pressed == LEFT_ARROW_KEY) {
    var button = document.getElementById('btnPrevious');
  20. @crapier crapier revised this gist Sep 17, 2015. 1 changed file with 334 additions and 345 deletions.
    679 changes: 334 additions & 345 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -6,15 +6,17 @@
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.6
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    // @grant GM_registerMenuCommand
    // @grant unsafeWindow
    // ==/UserScript==

    // Prevent script from running in frames and iframes
    if(window.top != window.self) {return;}
    if (window.top != window.self) {
    return;
    }

    // Get the pages jQuery
    var $ = unsafeWindow.jQuery;
    @@ -48,7 +50,7 @@ var video_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/
    //---------------------------------------------------------------------------------------------------------------
    if (home.test(url)) {
    console.log('Performing Cleaning for Home Page');

    // Remove Sections from the right side of the page
    //Get the rightside from the document
    var rightside = document.getElementById('rightside');
    @@ -60,12 +62,12 @@ if (home.test(url)) {
    if (rightside.children[i].childElementCount > 0) {
    // Check for children that to be removed
    if (rightside.children[i].children[0].textContent.search('Remove ads') > 0 ||
    rightside.children[i].children[0].textContent.search('Like me please') > 0 ||
    rightside.children[i].children[0].textContent.search('omments') > 0) {
    rightside.children[i].children[0].textContent.search('Like me please') > 0 ||
    rightside.children[i].children[0].textContent.search('omments') > 0) {
    // Remove Child if it matches, decrement index to account for removing the child
    rightside.removeChild(rightside.children[i--]);
    // Check if the next element is a clear2 div and remove it if it is
    if (i + 1 > - 1 && i + 1 < rightside.childElementCount) {
    if (i + 1 > -1 && i + 1 < rightside.childElementCount) {
    if (rightside.children[i + 1].className == 'clear2') {
    rightside.removeChild(rightside.children[i + 1]);
    }
    @@ -74,14 +76,14 @@ if (home.test(url)) {
    }
    }
    }

    // Remove Register link in nav sub bar
    var navsub = document.getElementById('navsubbar');
    if (navsub) {
    navsub.children[0].children[0].remove();
    navsub.children[0].childNodes[1].remove();
    }

    //Remove ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    @@ -104,20 +106,20 @@ if (home.test(url)) {
    if (adspace1) {
    adspace1.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremover = setInterval(function(){
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 100);
    }, 100);

    console.log('Done!');
    }

    @@ -126,7 +128,7 @@ if (home.test(url)) {
    //---------------------------------------------------------------------------------------------------------------
    if (anime_list.test(url)) {
    console.log('Performing Cleaning for Anime List Pages');

    // Remove large spaces left by empty adspace
    // Get the ads frame
    var adspace = document.getElementById('adsIfrme1');
    @@ -145,7 +147,7 @@ if (anime_list.test(url)) {
    // Remove the adspace's parent (and thus it)
    adspace.parentElement.remove();
    }

    //Remove other ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    @@ -159,20 +161,20 @@ if (anime_list.test(url)) {
    if (adspace2) {
    adspace2.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremover = setInterval(function(){
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 100);
    }, 100);

    console.log('Done!');
    }

    @@ -181,7 +183,7 @@ if (anime_list.test(url)) {
    //---------------------------------------------------------------------------------------------------------------
    if (anime_page.test(url)) {
    console.log('Performing Cleaning for Episode List Pages');

    // Remove large spaces left by empty adspace
    // Get the ads frame
    var adspace = document.getElementById('adsIfrme1');
    @@ -200,7 +202,7 @@ if (anime_page.test(url)) {
    // Remove the adspace's parent (and thus it)
    adspace.parentElement.remove();
    }

    //Remove other ads
    var leftad = document.getElementById('divFloatLeft');
    if (leftad) {
    @@ -214,7 +216,7 @@ if (anime_page.test(url)) {
    if (middlead) {
    middlead.remove();
    }

    // Remove share stuff from episode list pages
    var eplist = $('div.barContent.episodeList')[0].children[1];
    if (eplist) {
    @@ -233,7 +235,7 @@ if (anime_page.test(url)) {
    eplist.children[0].remove();
    }
    }

    // Remove comments
    var comment_location = 2;
    if (/kissasian/.test(url)) {
    @@ -243,25 +245,25 @@ if (anime_page.test(url)) {
    if (comments) {
    comments.remove();
    }

    var bookmark_link = document.getElementById('spanBookmark');
    if (bookmark_link) {
    bookmark_link.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremover = setInterval(function(){
    var adremover = setInterval(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 100);
    }, 100);

    console.log('Done!');
    }

    @@ -270,22 +272,22 @@ if (anime_page.test(url)) {
    //---------------------------------------------------------------------------------------------------------------
    if (video_page.test(url)) {
    console.log('Performing Cleaning for Video Page');

    // Override functions so they wont be do anything when called by the pages code
    // Function to inject into page
    var override = function () {
    DoDetect2 = function () {}
    CheckAdImage = function () {}
    }
    // Create script to inject
    var script1 = document.createElement('script');
    script1.type = "text/javascript";
    var override = function() {
    DoDetect2 = function() {}
    CheckAdImage = function() {}
    }
    // Create script to inject
    var script1 = document.createElement('script');
    script1.type = "text/javascript";
    script1.innerHTML = 'var override = ' + override.toString();
    // inject the script
    document.getElementsByTagName('head')[0].appendChild(script1);
    // Call our new function
    unsafeWindow.override();

    // Removes adspaces
    var adspace6 = document.getElementById('adsIfrme6');
    if (adspace6) {
    @@ -307,7 +309,7 @@ if (video_page.test(url)) {
    if (adspace11) {
    adspace11.remove();
    }

    var adCheck1 = document.getElementById('adCheck1');
    if (adCheck1) {
    adCheck1.remove();
    @@ -320,7 +322,7 @@ if (video_page.test(url)) {
    if (adCheck3) {
    adCheck3.remove();
    }

    var divdownload = document.getElementById('divDownload');
    if (divdownload) {
    divdownload.remove();
    @@ -329,17 +331,17 @@ if (video_page.test(url)) {
    if (divfilename) {
    divfilename.remove();
    }

    // Removes Empty spaces from Video pages
    // Remove Clears
    var vid_parent = document.getElementById('centerDivVideo').parentElement;
    for (var i = 0; i < vid_parent.childElementCount; i++) {
    if(vid_parent.children[i].className == 'clear' || vid_parent.children[i].className == 'clear2') {
    if (vid_parent.children[i].className == 'clear' || vid_parent.children[i].className == 'clear2') {
    vid_parent.removeChild(vid_parent.children[i--]);
    }
    }
    vid_parent.children[3].remove();

    // Get the comment section on the video pages
    var comments = document.getElementById('btnShowComments');
    // If it exist remove it and the element just prior to it also, share stuff of some kind
    @@ -350,167 +352,161 @@ if (video_page.test(url)) {
    comments.previousElementSibling.remove();
    comments.remove();
    }

    // remove comments for kisscartoon site
    var alt_comments = document.getElementById('divComments');
    if (alt_comments) {
    alt_comments.previousElementSibling.remove();
    alt_comments.previousElementSibling.remove();
    alt_comments.remove();
    }

    // Hide on page quality selector, conflicts with custom menu selector
    var page_select_player = document.getElementById('selectPlayer');
    if (page_select_player) {
    page_select_player.parentElement.style.cssText = 'display:none;';
    }

    // hide lights off feature that is pointless with ads already removed
    var lights_off = document.getElementById('switch');
    if (lights_off) {
    lights_off.remove();
    }

    // remove device player link and text
    $('.clsTempMSg').remove();


    var USE_FLASH_FOR_PAGE;
    if (player_option == PLAYER_FLASH) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingHTML5V1') < 0) {
    else if (/kissasian/.test(url) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // check if page actually has youtube info
    if (unsafeWindow.txha) {
    USE_FLASH_FOR_PAGE = true;
    }
    else {
    } else {
    USE_FLASH_FOR_PAGE = false;
    }
    }
    else {
    } else {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    else if (/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // check that page actually has html5 player
    if (unsafeWindow.myPlayer) {
    USE_FLASH_FOR_PAGE = false;
    }
    else {
    } else {
    USE_FLASH_FOR_PAGE = true;
    }
    }

    // Flash Player
    if (USE_FLASH_FOR_PAGE) {
    console.log('Using Flash Player');

    // Functions to inject on page for flash video control
    // Fires when youtube player is ready
    var onYouTubePlayerReady = function (playerId) {
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // translate option into youtubes quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    }
    else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    }
    else if (quality_option == '480') {
    youtube_quality_option = 'large';
    }
    else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // set the volume
    embedVideo.setVolume(volume_control);

    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function(){
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important")+30);
    var onYouTubePlayerReady = function(playerId) {
    console.log('Youtube Player Custom Controls Initialized');
    if (pause_option) {
    embedVideo.pauseVideo();
    }
    },100);
    }
    // Check for end of playback and move to next video
    var check_for_end = function (state) {
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    embedVideo.addEventListener('onStateChange', 'check_for_end');

    // translate option into youtubes quality strings values
    var youtube_quality_option;
    if (quality_option == '1080') {
    youtube_quality_option = 'hd1080';
    } else if (quality_option == '720') {
    youtube_quality_option = 'hd720';
    } else if (quality_option == '480') {
    youtube_quality_option = 'large';
    } else if (quality_option == '360') {
    youtube_quality_option = 'medium';
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // set the volume
    embedVideo.setVolume(volume_control);

    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function() {
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important") + 30);
    }
    }, 100);
    }
    // Check for end of playback and move to next video
    var check_for_end = function(state) {
    if (state == 0 && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    }
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }
    }
    }
    // Create script to inject
    var script2 = document.createElement('script');
    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var onYouTubePlayerReady = ' + onYouTubePlayerReady.toString() + '\n' +
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    'var check_for_end = ' + check_for_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });
    }
    // HTML5 Player
    else {
    console.log('Using HTML5 Player');

    // move quality select below player
    var html_quality_select = document.getElementById('selectQuality');
    if (html_quality_select) {
    @@ -521,7 +517,7 @@ if (video_page.test(url)) {
    video_area.parentElement.insertBefore(empty_div, video_area.nextSibling);
    leftover_text.remove();
    }

    // Functions to inject on page for html5 video control
    var html5_video_options = function() {
    console.log("HTML5 Player custom Controls Initialized");
    @@ -549,25 +545,25 @@ if (video_page.test(url)) {
    $('.clsTempMSg').remove();
    }
    // check if desired level is lower than all available
    else if(desired_level > parseInt(available_levels.options[0].innerHTML)) {
    else if (desired_level > parseInt(available_levels.options[0].innerHTML)) {
    available_levels.selectedIndex = 0;
    $('#selectQuality').change();
    $('.clsTempMSg').remove();
    }
    // else find level that is next smallest
    else {
    for (var i = 0; i < available_levels.length; i++) {
    if(desired_level > parseInt(available_levels.options[i].innerHTML)) {
    if (desired_level > parseInt(available_levels.options[i].innerHTML)) {
    available_levels.selectedIndex = i;
    $('#selectQuality').change();
    $('.clsTempMSg').remove();
    }
    }
    }
    }



    if (pause_option) {
    my_video_1_html5_api.pause();
    }
    @@ -578,60 +574,60 @@ if (video_page.test(url)) {
    var html5_video_end = function() {
    var button = document.getElementById('btnNext');
    if (button && autoplay_option && autoplay_count != 0) {
    if (autoplay_count > 0) {
    if (autoplay_count > 0) {
    autoplay_count--;
    if (autoplay_count == 0) {
    autoplay_count = -1;
    autoplay_option = false;
    }
    document.dispatchEvent(update_userscript);
    }
    var link = button.parentElement;
    document.location.href = link.href;
    }
    var link = button.parentElement;
    document.location.href = link.href;
    }
    }

    // injected speed controls
    var playback_decrease = function() {
    my_video_1_html5_api.playbackRate -= 0.25;
    }
    var playback_increase = function() {
    my_video_1_html5_api.playbackRate += 0.25;
    }

    // Create script to inject
    var script2 = document.createElement('script');
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    script2.innerHTML = 'var html5_video_options = ' + html5_video_options.toString() + '\n' +
    'var html5_video_end = ' + html5_video_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = ' + quality_option.toString() + '\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    'var html5_video_end = ' + html5_video_end.toString() + '\n' +
    'var pause_option = ' + pause_option.toString() + '\n' +
    'var quality_option = ' + quality_option.toString() + '\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    // Call the injected script
    unsafeWindow.html5_video_options();

    // Update values for userscript before switching to next video
    document.addEventListener('UDUS', function(event) {
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    autoplay_count = unsafeWindow.autoplay_count;
    autoplay_option = unsafeWindow.autoplay_option;
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });
    }

    // Scroll to the Container
    if (autoscroll_option) {
    document.getElementById('container').scrollIntoView(true);
    document.getElementById('container').scrollIntoView(true);
    }


    var resize_video_area = function() {
    var resize_to = window.innerWidth - 30;
    if (resize_to > 970) {
    @@ -640,80 +636,79 @@ if (video_page.test(url)) {
    document.getElementById('container').style.width = "" + (resize_to) + "px";
    document.getElementById('adsIfrme').style.width = "" + (resize_to - 20) + "px";
    $(".barContent")[0].children[0].style.width = "" + (resize_to - 40) + "px";

    document.getElementById('centerDivVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_to - 40)*552/845 + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";

    if (USE_FLASH_FOR_PAGE) {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40)*552/845 + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('embedVideo').style.height = "" + (resize_to - 40)*552/845 + "px";
    }
    else {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40)*552/845 + "px";
    document.getElementById('my_video_1').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('my_video_1').style.height = "" + (resize_to - 40)*552/845 + "px";
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('embedVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    } else {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    document.getElementById('my_video_1').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('my_video_1').style.height = "" + (resize_to - 40) * 552 / 845 + "px";
    }
    }

    if (resize_option) {
    window.addEventListener("resize", resize_video_area);
    // wait some for vid to get added to page, and initialy resize it
    setTimeout(function() {
    resize_video_area();
    }, 800);
    }


    // Keys listener for navigating between episodes with left and right arrow keys
    // Arrow key keycodes
    var LEFT_ARROW_KEY = 37;
    var RIGHT_ARROW_KEY = 39;
    var MINUS_DASH_KEY = 173;
    var PLUS_EQUALS_KEY = 61;
    var key_listener = function(event) {
    // Get which key is pressed
    var key_pressed = event.which;
    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    if ((USE_FLASH_FOR_PAGE && unsafeWindow.embedVideo.getPlayerState() == 2) || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)){
    // Left arrow key to go to previous video
    if (key_pressed == LEFT_ARROW_KEY) {
    var button = document.getElementById('btnPrevious');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    // Get which key is pressed
    var key_pressed = event.which;
    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    if ((USE_FLASH_FOR_PAGE && unsafeWindow.embedVideo.getPlayerState() == 2) || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)) {
    // Left arrow key to go to previous video
    if (key_pressed == LEFT_ARROW_KEY) {
    var button = document.getElementById('btnPrevious');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    // Prevent Default Action of scrolling
    event.preventDefault();
    }
    // Prevent Default Action of scrolling
    event.preventDefault();
    }
    // right arrow key for next video
    else if (key_pressed == RIGHT_ARROW_KEY) {
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    // right arrow key for next video
    else if (key_pressed == RIGHT_ARROW_KEY) {
    var button = document.getElementById('btnNext');
    if (button) {
    var link = button.parentElement;
    document.location.href = link.href;
    }
    // Prevent Default Action of scrolling
    event.preventDefault();
    }
    // Prevent Default Action of scrolling
    event.preventDefault();
    }
    }
    }
    // Speed controls for HTLM5 player (flash doesn't support atm)
    if (speed_control && !USE_FLASH_FOR_PAGE) {
    if (key_pressed == MINUS_DASH_KEY && unsafeWindow.my_video_1_html5_api.playbackRate > 0.25) {
    unsafeWindow.playback_decrease();
    }
    if (key_pressed == PLUS_EQUALS_KEY && unsafeWindow.my_video_1_html5_api.playbackRate < 5) {
    unsafeWindow.playback_increase();
    // Speed controls for HTLM5 player (flash doesn't support atm)
    if (speed_control && !USE_FLASH_FOR_PAGE) {
    if (key_pressed == MINUS_DASH_KEY && unsafeWindow.my_video_1_html5_api.playbackRate > 0.25) {
    unsafeWindow.playback_decrease();
    }
    if (key_pressed == PLUS_EQUALS_KEY && unsafeWindow.my_video_1_html5_api.playbackRate < 5) {
    unsafeWindow.playback_increase();
    }
    }
    }
    }
    // Add the listener for keypresses
    // Add the listener for keypresses
    document.addEventListener("keydown", key_listener);

    console.log('Done!');
    }

    @@ -769,8 +764,8 @@ if (footer) {
    }

    // Remove 'random' hides that appear on the sides of the page, all pages
    if($('div.divCloseBut')) {
    $('div.divCloseBut') .remove();
    if ($('div.divCloseBut')) {
    $('div.divCloseBut').remove();
    }

    // Keys listener for Script Menu Options
    @@ -806,9 +801,9 @@ var open_menu = function() {
    '<option value="360">360p</option>' +
    '<option value="480">480p</option>' +
    '<option value="720">720p</option>' +
    '<option value="1080">1080p</option>' +
    '<option value="1080">1080p</option>' +
    '</select></td></tr>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td>' +
    '<td align="right">Volume <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="volumepercent" id="volume_percent" min="0" max="100"></td></tr></table>' +
    '<center><input style="margin:2px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;padding:2px 5px 2px 5px;width:44px;height:27px;line-height:3px;" type="button" value="Save" id="menu_sumbit_button"></center></form>';

    @@ -841,21 +836,20 @@ var open_menu = function() {
    if (arrow_key_navagation) {
    arrow_nav_box.checked = true;
    }

    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    if (speed_control) {
    playback_speed_control_box.checked = true;
    }

    // Player radios
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    if (player_option == PLAYER_FLASH) {
    if (flash_option) {
    flash_option.checked = true;
    }
    }
    else if (player_option == PLAYER_HTML5) {
    } else if (player_option == PLAYER_HTML5) {
    if (html5_option) {
    html5_option.checked = true;
    }
    @@ -865,7 +859,7 @@ var open_menu = function() {
    if (quality_select) {
    quality_select.value = quality_option;
    }

    var volume_percent_input = document.getElementById('volume_percent');
    volume_percent_input.style.width = '40px';
    volume_percent_input.value = volume_control;
    @@ -874,94 +868,90 @@ var open_menu = function() {
    var submit_button = document.getElementById('menu_sumbit_button');
    // Save the values and close the menu
    submit_button.onclick = menu_save;
    }
    else {
    } else {
    menu_save();
    }
    }

    var menu_save = function() {
    // Get all of the form choices for checking
    var pause_option_box = document.getElementById('pause_option_box');
    var autoplay_option_box = document.getElementById('autoplay_option_box');
    var autoplay_count_input = document.getElementById('autoplay_count');
    var autoscroll_option_box = document.getElementById('autoscroll_option_box');
    var resize_option_box = document.getElementById('resize_option_box');
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    GM_setValue("auto", autoplay_option_box.checked);
    GM_setValue("scroll", autoscroll_option_box.checked);
    GM_setValue("auto_count", parseInt(autoplay_count_input.value));
    GM_setValue("resize", resize_option_box.checked);
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);

    // Check which player option is checked
    if (flash_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)){
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    }
    else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_FLASH;
    }
    else if (html5_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)){
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    // Get all of the form choices for checking
    var pause_option_box = document.getElementById('pause_option_box');
    var autoplay_option_box = document.getElementById('autoplay_option_box');
    var autoplay_count_input = document.getElementById('autoplay_count');
    var autoscroll_option_box = document.getElementById('autoscroll_option_box');
    var resize_option_box = document.getElementById('resize_option_box');
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    GM_setValue("auto", autoplay_option_box.checked);
    GM_setValue("scroll", autoscroll_option_box.checked);
    GM_setValue("auto_count", parseInt(autoplay_count_input.value));
    GM_setValue("resize", resize_option_box.checked);
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);

    // Check which player option is checked
    if (flash_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    } else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_FLASH;
    } else if (html5_option.checked) {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    if (/kissanime/.test(url) || /kisscartoon/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    } else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    }
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
    }
    player_option = PLAYER_HTML5;
    }
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;

    // Update this pages userscript options
    pause_option = pause_option_box.checked;
    autoplay_option = autoplay_option_box.checked;
    autoscroll_option = autoscroll_option_box.checked;
    arrow_key_navagation = arrow_nav_box.checked;
    autoplay_count = parseInt(autoplay_count_input.value);
    quality_option = quality_select.value;
    speed_control = playback_speed_control_box.checked;

    // Update unsafeWindow values that might matter if on video pages
    if (video_page.test(url)) {
    unsafeWindow.autoplay_option = autoplay_option_box.checked;
    unsafeWindow.autoplay_count = parseInt(autoplay_count_input.value);
    }
    player_option = PLAYER_HTML5;
    }

    // Update this pages userscript options
    pause_option = pause_option_box.checked;
    autoplay_option = autoplay_option_box.checked;
    autoscroll_option = autoscroll_option_box.checked;
    arrow_key_navagation = arrow_nav_box.checked;
    autoplay_count = parseInt(autoplay_count_input.value);
    quality_option = quality_select.value;
    speed_control = playback_speed_control_box.checked;

    // Update unsafeWindow values that might matter if on video pages
    if (video_page.test(url)) {
    unsafeWindow.autoplay_option = autoplay_option_box.checked;
    unsafeWindow.autoplay_count = parseInt(autoplay_count_input.value);
    menu.remove();
    menu_open = false;
    }

    menu.remove();
    menu_open = false;
    }
    // Add the listener for keypresses
    // Add the listener for keypresses
    document.addEventListener("keydown", global_key_listener);
    // Also add as GM menu command
    GM_registerMenuCommand("Options Menu", open_menu, "o");
    @@ -983,13 +973,13 @@ var UP_ARROW_KEY = 38;
    var DOWN_ARROW_KEY = 40;
    var ENTER_KEY = 13;
    // Prevent up and down arrow keys from causing the results to refresh
    var prevent_key_reg = function (event) {
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY || key_pressed == DOWN_ARROW_KEY) {
    event.stopPropagation();
    var prevent_key_reg = function(event) {
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY || key_pressed == DOWN_ARROW_KEY) {
    event.stopPropagation();
    }
    }
    }
    // Add above in the capture phase of event propagation, so it happens first
    // Add above in the capture phase of event propagation, so it happens first
    document.addEventListener('keyup', prevent_key_reg, true);
    // Intercept Enter key press to check if anything is selected
    var go_to_selection = function(event) {
    @@ -1007,53 +997,52 @@ var go_to_selection = function(event) {
    document.addEventListener('keydown', go_to_selection);
    // Navigate up and down in search results
    var navigate_search_results = function(event) {
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY) {
    if (search_selection > 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    search_results.children[--search_selection].style.backgroundColor = '#565E66';

    scroll_height -= search_results.children[search_selection + 1].clientHeight;
    if (search_selection == 0) {
    scroll_height = 0;
    }
    search_results.scrollTop = scroll_height;
    var key_pressed = event.which;
    if (key_pressed == UP_ARROW_KEY) {
    if (search_selection > 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    search_results.children[--search_selection].style.backgroundColor = '#565E66';

    scroll_height -= search_results.children[search_selection + 1].clientHeight;
    if (search_selection == 0) {
    scroll_height = 0;
    }
    search_results.scrollTop = scroll_height;
    }
    }
    }
    if (key_pressed == DOWN_ARROW_KEY) {
    if (search_selection < search_results.childElementCount - 1) {
    if (search_selection >= 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    if (key_pressed == DOWN_ARROW_KEY) {
    if (search_selection < search_results.childElementCount - 1) {
    if (search_selection >= 0) {
    search_results.children[search_selection].style.backgroundColor = '';
    }
    search_results.children[++search_selection].style.backgroundColor = '#565E66';
    scroll_height += search_results.children[search_selection - 1].clientHeight;
    search_results.scrollTop = scroll_height;
    }
    search_results.children[++search_selection].style.backgroundColor = '#565E66';
    scroll_height += search_results.children[search_selection - 1].clientHeight;
    search_results.scrollTop = scroll_height;
    }
    }
    }
    // Checks if there are navigatable results and adds navigate listener
    // Checks if there are navigatable results and adds navigate listener
    var reset_navigation = function() {
    search_selection = -1;
    scroll_height = 0;
    ++navigation_attempts;
    if (search_results.childElementCount > 0) {
    document.addEventListener('keydown', navigate_search_results);
    clearInterval(navigation_interval);
    }
    else {
    document.removeEventListener('keydown', navigate_search_results);
    if (navigation_attempts >= 10) {
    search_selection = -1;
    scroll_height = 0;
    ++navigation_attempts;
    if (search_results.childElementCount > 0) {
    document.addEventListener('keydown', navigate_search_results);
    clearInterval(navigation_interval);
    } else {
    document.removeEventListener('keydown', navigate_search_results);
    if (navigation_attempts >= 10) {
    clearInterval(navigation_interval);
    }
    }

    }

    }
    // Called everytime search text box input changes to see if there is navigatable results
    // Called everytime search text box input changes to see if there is navigatable results
    var try_navigation = function() {
    clearInterval(navigation_interval);
    navigation_attempts = 0;
    navigation_interval = setInterval(reset_navigation, 200);
    }
    search_form.addEventListener('input', try_navigation);

    console.log('Done!');
    console.log('Done!');
  21. @crapier crapier revised this gist Sep 16, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -19,14 +19,14 @@ Features
    * Player option (flash, html5) moved to KissAnime Clear menu (home key on keyboard)
    * Select preferred quality (should now work for both flash and html5)
    * Will attempt to set quality of video to selected value or next lowest value if selected is not available
    * Set Player Volume

    The script also works on KissCartoon and KissAsian for the most part.
    The script also works on KissCartoon and KissAsian.

    If a video page loads a HTML5 player when you have the flash player selected in the settings, then that video isn't available for flash, please switch to HTML5 player in the **HOME menu** for that page.

    Usage
    -----
    Only tested in FireFox with Greasemonkey.
    Only tested in FireFox with Greasemonkey (should work with Tapermonkey and Chrome).
    * Get Greasemonkey for FireFox if you don't already have it. [link](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/)
    * Click on the Raw link for **kissanime_cleaner.user.js** below, wait 5 seconds, and click install to add the script.

  22. @crapier crapier revised this gist Sep 16, 2015. 1 changed file with 59 additions and 24 deletions.
    83 changes: 59 additions & 24 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.5
    // @version 3.3.6
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -33,6 +33,7 @@ var player_option = GM_getValue("player", PLAYER_FLASH);
    var resize_option = GM_getValue("resize", true);
    var arrow_key_navagation = GM_getValue("arrow_nav", true);
    var speed_control = GM_getValue("speed_control", true);
    var volume_control = GM_getValue("volume_control", 100);

    // Current page url
    var url = document.location.href;
    @@ -372,9 +373,9 @@ if (video_page.test(url)) {

    // remove device player link and text
    $('.clsTempMSg').remove();


    // Flash Player

    var USE_FLASH_FOR_PAGE;
    if (player_option == PLAYER_FLASH) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingFlashV1') < 0) {
    @@ -390,8 +391,40 @@ if (video_page.test(url)) {
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }


    // check if page actually has youtube info
    if (unsafeWindow.txha) {
    USE_FLASH_FOR_PAGE = true;
    }
    else {
    USE_FLASH_FOR_PAGE = false;
    }
    }
    else {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // check that page actually has html5 player
    if (unsafeWindow.myPlayer) {
    USE_FLASH_FOR_PAGE = false;
    }
    else {
    USE_FLASH_FOR_PAGE = true;
    }
    }

    // Flash Player
    if (USE_FLASH_FOR_PAGE) {
    console.log('Using Flash Player');

    // Functions to inject on page for flash video control
    @@ -419,6 +452,11 @@ if (video_page.test(url)) {
    }
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);

    // set the volume
    embedVideo.setVolume(volume_control);

    // focus on the video (so pressing f will fullscreen)
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    @@ -455,6 +493,7 @@ if (video_page.test(url)) {
    'var quality_option = "' + quality_option.toString() + '"\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';

    // Inject the script
    @@ -470,21 +509,6 @@ if (video_page.test(url)) {
    }
    // HTML5 Player
    else {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }

    console.log('Using HTML5 Player');

    // move quality select below player
    @@ -542,9 +566,12 @@ if (video_page.test(url)) {
    }
    }



    if (pause_option) {
    my_video_1_html5_api.pause();
    }
    my_video_1_html5_api.volume = volume_control / 100;
    my_video_1_html5_api.addEventListener('ended', html5_video_end);
    setTimeout('my_video_1_html5_api.focus();', 0);
    }
    @@ -583,6 +610,7 @@ if (video_page.test(url)) {
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var volume_control = ' + volume_control.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    @@ -616,7 +644,7 @@ if (video_page.test(url)) {
    document.getElementById('centerDivVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('centerDivVideo').style.height = "" + (resize_to - 40)*552/845 + "px";

    if (player_option == PLAYER_FLASH) {
    if (USE_FLASH_FOR_PAGE) {
    document.getElementById('divContentVideo').style.width = "" + (resize_to - 40) + "px";
    document.getElementById('divContentVideo').style.height = "" + (resize_to - 40)*552/845 + "px";
    document.getElementById('embedVideo').style.width = "" + (resize_to - 40) + "px";
    @@ -650,7 +678,7 @@ if (video_page.test(url)) {
    var key_pressed = event.which;
    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    if (player_option == PLAYER_FLASH && unsafeWindow.embedVideo.getPlayerState() == 2 || (player_option == PLAYER_HTML5 && my_video_1_html5_api.paused)){
    if ((USE_FLASH_FOR_PAGE && unsafeWindow.embedVideo.getPlayerState() == 2) || (!USE_FLASH_FOR_PAGE && my_video_1_html5_api.paused)){
    // Left arrow key to go to previous video
    if (key_pressed == LEFT_ARROW_KEY) {
    var button = document.getElementById('btnPrevious');
    @@ -674,7 +702,7 @@ if (video_page.test(url)) {
    }
    }
    // Speed controls for HTLM5 player (flash doesn't support atm)
    if (speed_control && player_option == PLAYER_HTML5) {
    if (speed_control && !USE_FLASH_FOR_PAGE) {
    if (key_pressed == MINUS_DASH_KEY && unsafeWindow.my_video_1_html5_api.playbackRate > 0.25) {
    unsafeWindow.playback_decrease();
    }
    @@ -780,7 +808,8 @@ var open_menu = function() {
    '<option value="720">720p</option>' +
    '<option value="1080">1080p</option>' +
    '</select></td></tr>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td></tr></table>' +
    '<tr><td><input style="margin:2px;" type="radio" name="player" value="html5" id="html5_option"> HTML5 Player</td>' +
    '<td align="right">Volume <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="volumepercent" id="volume_percent" min="0" max="100"></td></tr></table>' +
    '<center><input style="margin:2px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;padding:2px 5px 2px 5px;width:44px;height:27px;line-height:3px;" type="button" value="Save" id="menu_sumbit_button"></center></form>';

    // Add menu to page
    @@ -836,6 +865,10 @@ var open_menu = function() {
    if (quality_select) {
    quality_select.value = quality_option;
    }

    var volume_percent_input = document.getElementById('volume_percent');
    volume_percent_input.style.width = '40px';
    volume_percent_input.value = volume_control;

    // Get the save button
    var submit_button = document.getElementById('menu_sumbit_button');
    @@ -859,6 +892,7 @@ var menu_save = function() {
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    var volume_percent_input = document.getElementById('volume_percent');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    @@ -869,6 +903,7 @@ var menu_save = function() {
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);
    GM_setValue("volume_control", volume_percent_input.value);

    // Check which player option is checked
    if (flash_option.checked) {
  23. @crapier crapier revised this gist Sep 12, 2015. 1 changed file with 0 additions and 11 deletions.
    11 changes: 0 additions & 11 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -104,17 +104,6 @@ if (home.test(url)) {
    adspace1.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremove = function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }
    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremover = setInterval(function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
  24. @crapier crapier revised this gist Sep 12, 2015. 1 changed file with 56 additions and 13 deletions.
    69 changes: 56 additions & 13 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.4
    // @version 3.3.5
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -105,7 +105,7 @@ if (home.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var adremove = function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    @@ -114,7 +114,19 @@ if (home.test(url)) {
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 1500);
    }
    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    var adremover = setInterval(function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 100);

    console.log('Done!');
    }
    @@ -159,16 +171,17 @@ if (anime_list.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var adremover = setInterval(function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 1500);
    }, 100);

    console.log('Done!');
    }
    @@ -247,16 +260,17 @@ if (anime_page.test(url)) {
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var adremover = setInterval(function(){
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    clearInterval(adremover);
    }
    }, 500);
    }, 100);

    console.log('Done!');
    }
    @@ -373,12 +387,21 @@ if (video_page.test(url)) {

    // Flash Player
    if (player_option == PLAYER_FLASH) {
    if (document.cookie.indexOf('usingFlashV1') < 0) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }


    console.log('Using Flash Player');

    @@ -458,12 +481,20 @@ if (video_page.test(url)) {
    }
    // HTML5 Player
    else {
    if (document.cookie.indexOf('usingHTML5V1') < 0) {
    // bookmarks for kissanime
    if ((/kissanime/.test(url) || /kisscartoon/.test(url)) && document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }
    // Bookmarks on kissasian and kisscartoon
    else if(/kissasian/.test(url) && document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }

    console.log('Using HTML5 Player');

    @@ -855,8 +886,14 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    if (/kissanime/.test(url) || /kisscartoon/.test(url)){
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    }
    else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    @@ -867,8 +904,14 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    if (/kissanime/.test(url) || /kisscartoon/.test(url)){
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    }
    else if (/kissasian/.test(url)) {
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    }
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
  25. @crapier crapier revised this gist Aug 27, 2015. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @include http://kissasian.com/*
    // @version 3.3.3
    // @version 3.3.4
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -114,7 +114,7 @@ if (home.test(url)) {
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 500);
    }, 1500);

    console.log('Done!');
    }
    @@ -168,7 +168,7 @@ if (anime_list.test(url)) {
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 500);
    }, 1500);

    console.log('Done!');
    }
    @@ -373,10 +373,10 @@ if (video_page.test(url)) {

    // Flash Player
    if (player_option == PLAYER_FLASH) {
    if (document.cookie.indexOf('usingHTML5V1') < 0) {
    if (document.cookie.indexOf('usingFlashV1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.location.href = document.location.href;
    }

    @@ -458,10 +458,10 @@ if (video_page.test(url)) {
    }
    // HTML5 Player
    else {
    if (document.cookie.indexOf('usingFlashV1') < 0) {
    if (document.cookie.indexOf('usingHTML5V1') < 0) {
    // Reload page with correct player
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.location.href = document.location.href;
    }

    @@ -855,8 +855,8 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_FLASH);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_FLASH && video_page.test(url)) {
    document.location.href = document.location.href;
    @@ -867,8 +867,8 @@ var menu_save = function() {
    // Update greasemonkey stored value
    GM_setValue("player", PLAYER_HTML5);
    // Set appropriate cookies
    document.cookie = 'usingFlashV1=true;path=/';
    document.cookie = 'usingHTML5V1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingFlashV1=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
    document.cookie = 'usingHTML5V1=true;path=/';
    // Reload page if value has changed
    if (player_option != PLAYER_HTML5 && video_page.test(url)) {
    document.location.href = document.location.href;
  26. @crapier crapier revised this gist Aug 11, 2015. 3 changed files with 50 additions and 53 deletions.
    10 changes: 3 additions & 7 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -20,18 +20,14 @@ Features
    * Select preferred quality (should now work for both flash and html5)
    * Will attempt to set quality of video to selected value or next lowest value if selected is not available

    The script also works on KissCartoon for the most part, the only issue is that some ads are not removed and KissCartoon videos do not have Flash versions for their videos so switch to HTML5 in the options and everything should work fine.

    Features - Lite
    ---------------
    * Only prevents Anti Adblock Scripts from running
    The script also works on KissCartoon and KissAsian for the most part.

    If a video page loads a HTML5 player when you have the flash player selected in the settings, then that video isn't available for flash, please switch to HTML5 player in the **HOME menu** for that page.

    Usage
    -----
    Only tested in FireFox with Greasemonkey.
    * Get Greasemonkey for FireFox if you don't already have it. [link](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/)
    * Click on the Raw link for **kissanime_cleaner.user.js** below, wait 5 seconds, and click install to add the script.
    * Alternatley click the Raw link for **kissanime_cleaner_antiantiadblock.user.js** below for the Lite version
    * Enable only one script at a time

    Feel free to borrow, modify, and/or steal any of the script for your own needs. No credit is required.
    53 changes: 47 additions & 6 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @version 3.3.2
    // @include http://kissasian.com/*
    // @version 3.3.3
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -36,10 +37,10 @@ var speed_control = GM_getValue("speed_control", true);
    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var home = /http:\/\/kissanime\.com\/$|http:\/\/kisscartoon\.me\/$/;
    var anime_list = /http:\/\/kissanime\.com\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$/;
    var video_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*/;
    var home = /http:\/\/kissanime\.com\/$|http:\/\/kisscartoon\.me\/$|http:\/\/kissasian\.com\/$/;
    var anime_list = /http:\/\/kissanime\.com\/(AnimeList|Genre|Status|Search|UpcomingAnime)|http:\/\/kisscartoon\.me\/(CartoonList|Status|Genre|Search)|http:\/\/kissasian\.com\/(DramaList|Status|Country|Genre|Search)/;
    var anime_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*$|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*$|http:\/\/kissasian\.com\/Drama\/[\w-]*$/;
    var video_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kisscartoon\.me\/Cartoon\/[\w-]*\/[\w-]*\?id=\n*|http:\/\/kissasian\.com\/Drama\/[\w-]*\/[\w-]*\?id=\n*/;

    //---------------------------------------------------------------------------------------------------------------
    // Clean Home page
    @@ -103,6 +104,18 @@ if (home.test(url)) {
    adspace1.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 500);

    console.log('Done!');
    }

    @@ -145,6 +158,18 @@ if (anime_list.test(url)) {
    adspace2.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 500);

    console.log('Done!');
    }

    @@ -207,7 +232,11 @@ if (anime_page.test(url)) {
    }

    // Remove comments
    var comments = $('div.bigBarContainer')[2];
    var comment_location = 2;
    if (/kissasian/.test(url)) {
    comment_location = 3;
    }
    var comments = $('div.bigBarContainer')[comment_location];
    if (comments) {
    comments.remove();
    }
    @@ -217,6 +246,18 @@ if (anime_page.test(url)) {
    bookmark_link.remove();
    }

    // Remove stubborn ads on kisscartoon that get added after the page loads (hopefully after they load)
    setTimeout(function() {
    var left_cartoon = document.getElementById('cpmstar-site-skin-l');
    if (left_cartoon) {
    left_cartoon.remove();
    }
    var right_cartoon = document.getElementById('cpmstar-site-skin-r');
    if (right_cartoon) {
    right_cartoon.remove();
    }
    }, 500);

    console.log('Done!');
    }

    40 changes: 0 additions & 40 deletions kissanime_cleaner_antiantiadblock.user.js
    Original file line number Diff line number Diff line change
    @@ -1,40 +0,0 @@
    // ==UserScript==
    // @name KissAnime Cleaner Lite
    // @namespace 9001
    // @description Just prevents the Anti-adblock from running
    // @include http://kissanime.com/*
    // @version 2.0
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner_antiantiadblock.user.js
    // @grant unsafeWindow
    // ==/UserScript==

    // Prevent script from running in frames and iframes
    if(window.top != window.self) {return;}

    // Current page url
    var url = document.location.href;
    // Regular Expressions to check against for determining what type page currently on and what to clean
    var video_page = /http:\/\/kissanime\.com\/Anime\/[\w-]*\/[\w-]*\?id=\n*/;

    // Only run on video pages
    if (video_page.test(url)) {
    console.log('Performing AntiAdblock for Video Page');

    // Override functions so they wont be do anything when called by the pages code
    // Function to inject into page
    var override = function () {
    DoDetect2 = function () {}
    CheckAdImage = function () {}
    }
    // Create script to inject
    var script1 = document.createElement('script');
    script1.type = "text/javascript";
    script1.innerHTML = 'var override = ' + override.toString();
    // inject the script
    document.getElementsByTagName('head')[0].appendChild(script1);
    // Call our new function
    unsafeWindow.override();

    // Finished
    console.log('Done!');
    }
  27. @crapier crapier revised this gist Jul 26, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,8 @@ Features
    * Player option (flash, html5) moved to KissAnime Clear menu (home key on keyboard)
    * Select preferred quality (should now work for both flash and html5)
    * Will attempt to set quality of video to selected value or next lowest value if selected is not available

    The script also works on KissCartoon for the most part, the only issue is that some ads are not removed and KissCartoon videos do not have Flash versions for their videos so switch to HTML5 in the options and everything should work fine.

    Features - Lite
    ---------------
  28. @crapier crapier revised this gist Jul 14, 2015. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @version 3.3.1
    // @version 3.3.2
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -328,6 +328,7 @@ if (video_page.test(url)) {

    // remove device player link and text
    $('.clsTempMSg').remove();


    // Flash Player
    if (player_option == PLAYER_FLASH) {
    @@ -366,6 +367,13 @@ if (video_page.test(url)) {
    // set the quality
    embedVideo.setPlaybackQuality(youtube_quality_option);
    setTimeout('embedVideo.focus();', 0);

    // Force position to be absolute (compatibility with 'Turn Off the Lights')
    setTimeout(function(){
    if (embedVideo.style.cssText.indexOf("position: relative !important") >= 0) {
    embedVideo.style.cssText = embedVideo.style.cssText.substr(0, embedVideo.style.cssText.indexOf("position: relative !important;")) + embedVideo.style.cssText.substr(embedVideo.style.cssText.indexOf("position: relative !important")+30);
    }
    },100);
    }
    // Check for end of playback and move to next video
    var check_for_end = function (state) {
    @@ -406,7 +414,6 @@ if (video_page.test(url)) {
    GM_setValue("auto", autoplay_option);
    GM_setValue("auto_count", autoplay_count);
    });

    }
    // HTML5 Player
    else {
  29. @crapier crapier revised this gist Jul 9, 2015. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @version 3.3.0
    // @version 3.3.1
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -498,11 +498,9 @@ if (video_page.test(url)) {

    // injected speed controls
    var playback_decrease = function() {
    console.log("decrease speed");
    my_video_1_html5_api.playbackRate -= 0.25;
    }
    var playback_increase = function() {
    console.log("increase speed");
    my_video_1_html5_api.playbackRate += 0.25;
    }

    @@ -610,11 +608,9 @@ if (video_page.test(url)) {
    // Speed controls for HTLM5 player (flash doesn't support atm)
    if (speed_control && player_option == PLAYER_HTML5) {
    if (key_pressed == MINUS_DASH_KEY && unsafeWindow.my_video_1_html5_api.playbackRate > 0.25) {
    console.log("decreaseing speed");
    unsafeWindow.playback_decrease();
    }
    if (key_pressed == PLUS_EQUALS_KEY && unsafeWindow.my_video_1_html5_api.playbackRate < 5) {
    console.log("increasing speed");
    unsafeWindow.playback_increase();
    }
    }
  30. @crapier crapier revised this gist Jul 9, 2015. 2 changed files with 40 additions and 4 deletions.
    1 change: 1 addition & 0 deletions Kissanime_cleaner.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ Features
    * Automatically scroll down some on video pages
    * Resize Video Area to keep it centered and visible in smaller windows
    * Use the arrow keys to go to the previous or next video (only when video is paused)
    * Use the - and = keys to increase and decrease the playback speed for HTML5 player (flash player does not provide support)
    * Player option (flash, html5) moved to KissAnime Clear menu (home key on keyboard)
    * Select preferred quality (should now work for both flash and html5)
    * Will attempt to set quality of video to selected value or next lowest value if selected is not available
    43 changes: 39 additions & 4 deletions kissanime_cleaner.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @description Cleans up KissAnime pages. Tested to work with Firefox and Greasemonkey.
    // @include http://kissanime.com/*
    // @include http://kisscartoon.me/*
    // @version 3.2.7
    // @version 3.3.0
    // @downloadURL https://gist.github.com/crapier/91926a6353207f4524cc/raw/kissanime_cleaner.user.js
    // @grant GM_getValue
    // @grant GM_setValue
    @@ -31,6 +31,7 @@ var autoscroll_option = GM_getValue("scroll", true);
    var player_option = GM_getValue("player", PLAYER_FLASH);
    var resize_option = GM_getValue("resize", true);
    var arrow_key_navagation = GM_getValue("arrow_nav", true);
    var speed_control = GM_getValue("speed_control", true);

    // Current page url
    var url = document.location.href;
    @@ -494,6 +495,17 @@ if (video_page.test(url)) {
    document.location.href = link.href;
    }
    }

    // injected speed controls
    var playback_decrease = function() {
    console.log("decrease speed");
    my_video_1_html5_api.playbackRate -= 0.25;
    }
    var playback_increase = function() {
    console.log("increase speed");
    my_video_1_html5_api.playbackRate += 0.25;
    }

    // Create script to inject
    var script2 = document.createElement('script');
    script2.type = "text/javascript";
    @@ -503,6 +515,8 @@ if (video_page.test(url)) {
    'var quality_option = ' + quality_option.toString() + '\n' +
    'var autoplay_option = ' + autoplay_option.toString() + '\n' +
    'var autoplay_count = ' + autoplay_count.toString() + '\n' +
    'var playback_decrease = ' + playback_decrease.toString() + '\n' +
    'var playback_increase = ' + playback_increase.toString() + '\n' +
    'var update_userscript = new Event("UDUS")';
    // Inject the script
    document.getElementsByTagName('head')[0].appendChild(script2);
    @@ -563,10 +577,11 @@ if (video_page.test(url)) {
    // Arrow key keycodes
    var LEFT_ARROW_KEY = 37;
    var RIGHT_ARROW_KEY = 39;
    var MINUS_DASH_KEY = 173;
    var PLUS_EQUALS_KEY = 61;
    var key_listener = function(event) {
    // Get which key is pressed
    var key_pressed = event.which;

    if (arrow_key_navagation) {
    // check to make sure video isnt playing
    if (player_option == PLAYER_FLASH && unsafeWindow.embedVideo.getPlayerState() == 2 || (player_option == PLAYER_HTML5 && my_video_1_html5_api.paused)){
    @@ -592,6 +607,17 @@ if (video_page.test(url)) {
    }
    }
    }
    // Speed controls for HTLM5 player (flash doesn't support atm)
    if (speed_control && player_option == PLAYER_HTML5) {
    if (key_pressed == MINUS_DASH_KEY && unsafeWindow.my_video_1_html5_api.playbackRate > 0.25) {
    console.log("decreaseing speed");
    unsafeWindow.playback_decrease();
    }
    if (key_pressed == PLUS_EQUALS_KEY && unsafeWindow.my_video_1_html5_api.playbackRate < 5) {
    console.log("increasing speed");
    unsafeWindow.playback_increase();
    }
    }
    }
    // Add the listener for keypresses
    document.addEventListener("keydown", key_listener);
    @@ -674,13 +700,14 @@ var open_menu = function() {
    menu_open = true;
    // Make div element for menu
    menu = document.createElement('div');
    menu.style.cssText = 'color:black;width:250px;height:250px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.style.cssText = 'color:black;width:250px;height:270px;background-color:white;position:fixed;top:0;bottom:0;left:0;right:0;margin:auto;border:5px solid;border-radius:10px;border-color:#7FCA03;padding:10px;z-index:5;';
    menu.innerHTML = '<center><b>KissAnime Cleaner Options</b></center>' +
    '<form><input style="margin:2px;" type="checkbox" name="pause" value="true" id="pause_option_box"> Pause Videos on Page Load <br>' +
    '<input style="margin:2px;" type="checkbox" name="autoplay" value="true" id="autoplay_option_box"> Automatically Play Next <input style="margin:0px;font-size:111%;font-family:Tahoma,Arial,Helvetica,sans-serif;" type="number" name="autoplaycount" id="autoplay_count" min="-1" max="999"> Video(s) (choose -1 to play all)<br>' +
    '<input style="margin:2px;" type="checkbox" name="autoscroll" value="true" id="autoscroll_option_box"> Automatically Scroll Down to Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="resize" value="true" id="resize_option_box"> Resize Video Area <br>' +
    '<input style="margin:2px;" type="checkbox" name="arrow_nav" value="true" id="arrow_nav_box"> Arrow Keys Navigate Between Videos <br><br>' +
    '<input style="margin:2px;" type="checkbox" name="arrow_nav" value="true" id="arrow_nav_box"> Arrow Keys Navigate Between Videos <br>' +
    '<input style="margin:2px;" type="checkbox" name="speed_playback" value="true" id="playback_speed_control_box"> Enable HTML5 Playback speed controls <br><br>' +
    '<center><b>Player Options</b></center>' +
    '<table style="width: 100%;border-collapse:separate;border-spacing:2px;"><tr><td><input style="margin:2px;" type="radio" name="player" value="flash" id="flash_option"> Flash Player</td>' +
    '<td align="right"><select style="margin:2px;" id="quality_select">' +
    @@ -722,6 +749,11 @@ var open_menu = function() {
    arrow_nav_box.checked = true;
    }

    var playback_speed_control_box = document.getElementById('playback_speed_control_box');
    if (speed_control) {
    playback_speed_control_box.checked = true;
    }

    // Player radios
    var flash_option = document.getElementById('flash_option');
    var html5_option = document.getElementById('html5_option');
    @@ -762,6 +794,7 @@ var menu_save = function() {
    var html5_option = document.getElementById('html5_option');
    var quality_select = document.getElementById('quality_select');
    var arrow_nav_box = document.getElementById('arrow_nav_box');
    var playback_speed_control_box = document.getElementById('playback_speed_control_box');

    // Update Greasemonkey stored values for options
    GM_setValue("pause", pause_option_box.checked);
    @@ -771,6 +804,7 @@ var menu_save = function() {
    GM_setValue("resize", resize_option_box.checked);
    GM_setValue("arrow_nav", arrow_nav_box.checked);
    GM_setValue("quality", quality_select.value);
    GM_setValue("speed_control", playback_speed_control_box.checked);

    // Check which player option is checked
    if (flash_option.checked) {
    @@ -805,6 +839,7 @@ var menu_save = function() {
    arrow_key_navagation = arrow_nav_box.checked;
    autoplay_count = parseInt(autoplay_count_input.value);
    quality_option = quality_select.value;
    speed_control = playback_speed_control_box.checked;

    // Update unsafeWindow values that might matter if on video pages
    if (video_page.test(url)) {