Lopol2010 / torjackan

// ==UserScript==
// @name torjackan
// @description TORJACKAN
// @license MIT
// @include *://openload.co/*
// @include *://torjackan.info/*
// @version 1.24
// @run-at document-start|document-end
// @require https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

(function() {
	if(!window.location.href.includes('torjackan.') || window != window.top){
		return
	}

	// выбираем целевой элемент
	var target = $('body')[0]

	// создаём экземпляр MutationObserver
	var observer = new MutationObserver(function(mutations) {

		mutations.forEach(function(mutation) {

			var $cur = $(mutation.addedNodes)
			var $cur2 = $(mutation.target)

			if($cur.css('z-index') > 0 || $cur.is('script, iframe, .padPreload')){

				console.log($cur)

				//$cur.remove()
			//	$cur2.remove()
			}

		})
		//.padPreload, div[style*="z-index"], 
	//	$('script, iframe:not([src*="openload"])').remove()

		//defuse all links
		$('a[href*="ouo"]').each(function() {
			this.href = decodeURIComponent(this.href.replace(/.*=/, ''))
		})

		//remove everything constains 'ad' in class name
		$('div, p').each(function (){
			if(this.className.match(/ad/i))
				this.remove()
		})

	})

	// конфигурация нашего observer:
	var config = { attributes: true, childList: true, characterData: true }

	// передаём в качестве аргументов целевой элемент и его конфигурацию
	observer.observe(target, config)

	// позже можно остановить наблюдение
	// observer.disconnect()

	// //remove dynamic elements
	// removeDynamicElement('div[style*="z-index"]')
	// removeDynamicElement('script, iframe, .padPreload')

	// function removeDynamicElement(selectors) {

		// continousExecution(20, 10, function() {
		// 	var $elements = $(selectors).not('[src*="openload"]')

		// 	$elements.each(function(i) {
		// 			this.remove()
		// 			console.log(this.className)
		// 	})
		// })
	// }


	// function continousExecution(interval, count, func) {

	// 	var observePopupAds = setInterval(function() {
	// 		func()
	// 		if(--count <= 0){
	// 			clearInterval(observePopupAds)
	// 		}
	// 	}, interval)
	// }
})()