Skip to content

Instantly share code, notes, and snippets.

@al1b
Last active August 17, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al1b/dde5931c7979b53c5dc514aeceb9e76f to your computer and use it in GitHub Desktop.
Save al1b/dde5931c7979b53c5dc514aeceb9e76f to your computer and use it in GitHub Desktop.
Replace Simple Blocking Page
// ==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