levushka / IFRAME/FLASH switcher

// ==UserScript==
// @name       IFRAME/FLASH switcher
// @namespace  http://www.kitsis.ca/
// @version    0.10
// @description  Allow to activate or deactivate all Iframes and Flash objects individualy
// @grant      unsafeWindow
// @updateURL  https://openuserjs.org/install/levushka/IFRAMEFLASH_switcher.user.js
// @installURL https://openuserjs.org/install/levushka/IFRAMEFLASH_switcher.user.js
// @downloadURL https://openuserjs.org/install/levushka/IFRAMEFLASH_switcher.user.js
// @include    http://good-zona.ru/*
// @include    http://goodzona.co/*
// @include    http://vodly.to/*
// @copyright  2014+, Lev Kitsis
// ==/UserScript==


function processObj(key, swichObj) {
  var $swichObj = $(swichObj);
  var $btn_swich = $('<div><span class="btn_swich swich_deactive"><b><font color=blue size=3>SWICH '+$swichObj.prop("tagName")+' ['+($swichObj.attr('src') || 'no SRC').substring(0,40)+']</font></b></span><div class="container"></div></div>');
  $btn_swich.find('.btn_swich').data('sHtml', $swichObj[0].outerHTML);
  $swichObj.before($btn_swich);
  $swichObj.remove();
}

function check_iframes() {
  $('iframe').each(processObj);
  $('object').each(processObj);
  $('embed').each(processObj);
  $('.btn_swich').on('click', switch_obj);
}

function switch_obj(eventObject) {
    var $btn = $(this);
   
    if($btn.hasClass( 'swich_deactive' )) {
      $btn.removeClass('swich_deactive');
      $btn.next().html($btn.data('sHtml'));  
    } else {
      $btn.addClass('swich_deactive');
      $btn.next().empty();  
    }
}



var url = location.href;

unsafeWindow.switch_obj = switch_obj;

if(typeof $ === 'function') {
  check_iframes();
} else if(console && console.log) {
  console.log('IFRAME/FLASH switcher: jQuery is not defined', unsafeWindow);
}