Open
Conversation
ThrawnCA
reviewed
Nov 22, 2018
| "surrogate.oracle_downloads.sources": "!^https?://(?:www\\.)oracle\\.com/.+?/downloads/[^\\/]+?-downloads-.+$", | ||
| "surrogate.oracle_downloads.replacement" : "document.cookie = 'oraclelicense=accept-securebackup-cookie; domain=.oracle.com; path=/; expires=' +(new Date(Date.now() + 1800000)).toGMTString();", | ||
| "surrogate.microsoft_kb.sources" : "!https?://support\\.microsoft\\.com/(\\w{2}-\\w{2,3}/help|kb)/\\d+(/.+)?", | ||
| "surrogate.microsoft_kb.replacement" : "'use strict';let ce=document.createElement.bind(document);let r=/microsoft\\.support\\.prefetchedArticle\\s*=\\s*\\(\\s*function\\s*\\(\\s*\\)\\s*\\{\\s*return\\s+([^]+?)\\}\\)\\(\\);/m;let x=/'([a-z]{2}(?:-[a-z]{2})?\\/\\d+)'/g;let t;for(let w of document.getElementsByTagName('SCRIPT')){if(!w.src){let m=w.textContent.match(r);if(m){t=m[1].replace(x,'\"$1\"');break;}}}let j=JSON.parse(t),M=document.getElementById('mainContent');function A(a,b){a=new Date(a);var g=ce('time'),n=ce('p');n.textContent=b;g.a=a;g.textContent=a;n.appendChild(g);M.appendChild(n);}M.innerHTML='';for(let B in j){var d=j[B].details,h=ce('h1');document.head.title=h.textContent='KB'+d.id+' - '+d.heading;M.appendChild(h);A(d.createdOn,'created: ');A(d.publishedOn,'published: ');var s=ce('section');s.textContent=d.description;M.appendChild(s);for(var body of d.body){let S=ce('section'),J=ce('h3');J.textContent=body.title;S.appendChild(J);var P=ce('p');P.innerHTML=body.content;S.appendChild(P);M.appendChild(S)}var a=ce('a');a.textContent='Download JSON';a.download='KB'+d.id+'.json';a.href=URL.createObjectURL(new Blob([JSON.stringify(j,null,'\\t')],{type:'application/json'}));a.style.color='blue';M.appendChild(a);break;}", |
There was a problem hiding this comment.
What does this actually do? There's a lot of it for a simple surrogate.
Author
There was a problem hiding this comment.
parses data encoded into a JS object (by carving them with regexp, fixing quotes to make a valid JSON and then using JSON.parse, no actual code execution involved) and renderes them. Also adds a link to download them as JSON.
ThrawnCA
reviewed
Nov 22, 2018
| "surrogate.goszakupki.sources" : "!https?://zakupki\\.gov\\.ru/.+", | ||
| "surrogate.goszakupki.replacement" : "'use strict';for(let el of document.querySelectorAll('[url]')){let a=document.createElement('A');a.href=el.getAttribute('url');let spn=el.getElementsByTagName('SPAN')[0];a.innerHTML=spn.innerHTML;a.className=spn.className;spn.replaceWith(a);}", | ||
| "surrogate.cloud_mail_ru.sources":"!^https://cloud\\.mail\\.ru/(stock|public)/.+$", | ||
| "surrogate.cloud_mail_ru.replacement":"'use strict';const rx=/require.config\((\{[^]+?\})\)/;const entRx=/\\x([\da-fA-F]+)/g;function getConfig(){let scripts=[...document.querySelectorAll('script:not([class]):not([src])')];let text=scripts.map((s)=>s.textContent.match(rx)).filter(j=>!!j)[0][1];text=text.replace(entRx,(...e)=>String.fromCodePoint(parseInt(e[1],16)));let config=JSON.parse(text);return config;}function getToken(){fetch('https://cloud.mail.ru/api/v2/tokens/download').then((res)=>{return res.json().then((res)=>{return new Promise(function(resolve,reject){let b=res['body'];if(b){let t=b['token'];if(t){console.log('token:',t);resolve(t);console.log('never called');}}console.error('No token present');reject('No token present: error code '+res['status']);});});}).then(token=>console.log(token));};const config=getConfig();const cls=config['config']['Cloud/settings'];const notifEl=document.querySelector('.b-page-content-loader__message-text_nojs');const stockBase=cls['dispatcher']['stock'][0]['url'];const weblinkBase=cls['dispatcher']['weblink_get'][0]['url'];var processMapping={'file':function(file,parentName){console.info(file);let fileName=file['name'];let id=file['id'];let url;if(file['dwl_token']){url=stockBase+'get/'+file['dwl_token']+'/'+encodeURIComponent(fileName);}else{url=cls['dispatcher']['weblink_get'][0]['url']+'/'+id+'/'+encodeURIComponent(fileName);}a=document.createElement('A');a.href=url;a.download=fileName;a.textContent=`${parentName}${fileName}(${file['size']}bytes,virus scan:${file['virus_scan']})`;return a;},'folder':function(folderObj,parentName){let cont=document.createElement('UL');for(var file of folderObj['list']){let child=processMapping[file['kind']](file,parentName+folderObj['id']);let it=document.createElement('LI');it.appendChild(child);cont.appendChild(it);}return cont;}};noti fEl.appendChild(processMapping['folder'](cls['folders']['folder'],''));", |
Author
There was a problem hiding this comment.
Renders files list from JS object.
Author
a578ed7 to
c7bf7f0
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.