⬆️ ⬇️

Standards for GreaseMonkey'vski

A colleague came up recently and said that she couldn’t save the GOST page from the unloved site http://protect.gost.ru .

“Should we be sad, old lady,” I told her, opened the above-mentioned website and began to pick watch.



It turned out that the “protection” algorithm is quite simple - a picture with a GOST page is superimposed by a css-style on a transparent picture: pixel. As a result, when you try to save a picture through “Save image as ..” in Firefox, we save the GOST page we don't need, but pixel.gif.

“Laziness is the engine of progress,” I thought, and put on a small crease for GreaseMonkey, which I share with the readers.

 // ==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 are able to save exactly the page we need.

Works great in Firefox 3.6.3 + GreaseMonkey 0.8.20100408.6



Habraphews nanodust prompted an already existing script with similar functionality on UserScript.org (I apologize for shortening the link, there is not enough experience to trick the habraparser).



Habrapapyuser david_mz wrote a bookmarklet for deploying GOST:

"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, you need to take a piece of bookmarklet in a “working” form and make a bookmark in the browser, which has this code instead of a URL. Then go to any page of the required GOST (on the page, not the annotation) and click on the tab. All pages of this GOST will appear in the form of pictures without any protection.

Source: https://habr.com/ru/post/90615/



All Articles