User:KurwaAntics/common.js

From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
if( window.location.href.indexOf('T:') > -1) window.location.href = window.location.href.replace('T:','Template:');
if( window.location.href.indexOf('Css') > -1) window.location.href = window.location.href.replace('Css','User:UntergangerPlus/vector.css');
if( window.location.href.indexOf('Js') > -1) window.location.href = window.location.href.replace('Js','User:UntergangerPlus/common.js');

$('a[href*="youtu.be/"]').on('click', function(){
    if ($(".greyout")[0]){
        return false;
    } else {
        var id = $(this).attr('href').split('.be/')[1].split('?')[0];
        $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1" frameborder="0"></iframe></div>');
        $('.close-modal').on('click', function() {
            $(".greyout, .mymodal").remove();
        });
        return false;
    }
});

$('a[href*="youtube.com/watch"]').on('click', function(){
    if ($(".greyout")[0]){
        return false;
    } else {
        var id = $(this).attr('href').split('?v=')[1].split('&')[0];
        $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1" frameborder="0"></iframe></div>');
        $('.close-modal').on('click', function() {
            $(".greyout, .mymodal").remove();
        });
        return false;
    }
});