-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added some surrogates #12
base: main
Are you sure you want to change the base?
Conversation
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this actually do? There's a lot of it for a simple surrogate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"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'],''));", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this surrogate do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renders files list from JS object.
a578ed7
to
c7bf7f0
Compare
No description provided.