GOST according to GreaseMonkey

    A colleague recently came up and told me that she couldn’t manage to save the GOST page from the unfriendly site http://protect.gost.ru .
    “Should we be sad, old woman,” I told her, I opened the aforementioned website and began to pick my watch.

    It turned out that the “protection” algorithm is quite simple - a picture with a GOST page is superimposed with a css-style on a transparent picture pixel.gif. As a result, when we try to save the image via “Save Image As ..” in Firefox, we save not the GOST page we need, but pixel.gif.
    "Laziness is the engine of progress," I thought, and I threw a small script for GreaseMonkey, which I share with habrachitateli.
    // ==UserScript==
    // @name           GostRu
    // @namespace      http://protect.gost.ru/*
    // @description    Delete pixel image under Gost
    // @include        http://protect.gost.ru/*
    // ==/UserScript==
    var s_l=document.styleSheets.length;
    for (j=0;j<s_l;j++) {
        var st=document.styleSheets[j].cssRules,
            st_l=st.length;
        for (i=0;i<st_l;i++) {
            if (st[i].selectorText==='.face') {
                im=st[i].style.backgroundImage;
                break;
            }
        }
    }
    im=im.split('"')[1];
    if (im!=='') {
    	var img=document.getElementsByTagName('img'),
    	    img_l=img.length;
    	for (i=0;i<img_l;i++) {
    	    if (img[i].className==='face') {
    		img[i].src=im;
    	    }
    	}
    }
    

    After installing the script, we get the opportunity to save exactly the page we need.
    Works fine in Firefox 3.6.3 + GreaseMonkey 0.8.20100408.6

    Habrapolzovatel nanodust prompted an existing script with the same functionality on UserScript.org (sorry for shorten links, not enough experience to "deception" habraparsera).

    The user david_mz wrote a bookmarklet for deploying GOSTs: a
    "working" version:
    javascript:(function() { var ids = []; for(var i=0;i<document.links.length;i++) { var a = document.links[i]; if (a.href.indexOf('&pageK=') < 0 || !a.firstChild) continue; ids.push(a.href.substr(a.href.indexOf('pageK=') + 6, 36)); } document.open(); document.write('<html><body></body></html>'); document.close(); for(var i=0;i<ids.length;i++) { var img = document.createElement('img'); img.src="image.ashx?page="+ids[i]; document.body.appendChild(img); } })();


    "Readable" version:
    javascript:(
    	function() {
    		var ids = [];
    		for(var i=0;i<document.links.length;i++) {
    			var a = document.links[i];
    			if (a.href.indexOf('&pageK=') < 0 || !a.firstChild) continue;
    			ids.push(a.href.substr(a.href.indexOf('pageK=') + 6, 36));
    		}
    		document.open();
    		document.write('<html><body></body></html>');
    		document.close();
    		for(var i=0;i<ids.length;i++) {
    			var img = document.createElement('img');
    			img.src="image.ashx?page="+ids[i];
    			document.body.appendChild(img);
    		}
    	}
    )();

    Method of application: for real work, it is necessary to take a piece of the bookmarklet in the “working” form and make a bookmark in the browser that has this code instead of the URL. Then go to any page of the required GOST (namely, the page, not the annotation) and click on the bookmark. All pages of this GOST will appear in the form of pictures without any protection.

    Also popular now: