Last active
August 17, 2017 07:31
-
-
Save al1b/dde5931c7979b53c5dc514aeceb9e76f to your computer and use it in GitHub Desktop.
Replace Simple Blocking Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Simple Blocking Page | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Replace payvandha.ir with a simpler page. | |
// @author You | |
// @grant none | |
// @include * | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var isPeyvandHa = false; | |
var src = ""; | |
var iframes = document.getElementsByTagName("iframe"); | |
if(iframes.length === 0) | |
return; | |
src = iframes[0].getAttribute("src").toLowerCase(); | |
var queryString = "?type=Invalid Site&policy=MainPolicy".toLowerCase(); | |
isPeyvandHa = src.indexOf(queryString) >= 0 || | |
window.location.toString().toLowerCase().indexOf("peyvandha.ir") >= 0 || | |
src.indexOf('http://10.10.34.34') >= 0; | |
if(isPeyvandHa){ | |
removeAll(iframes.length > 0 ? iframes : document.body.location); | |
displayBlockPage(); | |
} | |
})(); | |
function removeAll(items){ | |
for(var i=0;i<items.length;i++) | |
items[i].remove(); | |
} | |
function displayBlockPage(){ | |
document.title = "دسترسی به تارنمای مورد نظر امکان پذیر نمی باشد."; | |
var anchor = "<a class='link' href='" + window.location + "'>" + window.location + "</a>"; | |
document.body.innerHTML = "<p>دسترسی به تارنما مورد نظر امکانپذیر نمیباشد. شما در حال مشاهده آدرس " + anchor + ' هستید. <p/>'; | |
var style = document.createElement("style"); | |
style.setAttribute("type", "text/css"); | |
style.innerHTML = "p{font-family:Tahoma; font-size:12px;text-align:right;direction:rtl;color:red;}.link{direction:ltr;text-align:left;font-weight:bold}"; | |
document.head.appendChild(style); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment