Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (() => {
- const ID = window.content_id;
- const PAGES_URL = 'https://urait.ru/viewer/getData/' + ID;
- const PAGE_URL = 'https://urait.ru/viewer/getPage/' + ID + '/$1';
- const HEADERS = {
- 'X-Requested-With': 'XMLHttpRequest'
- };
- /*** COMMON ***/
- function addCSS(css) {
- let styleElem = document.createElement( 'style' );
- styleElem.appendChild( document.createTextNode( css ) );
- document.getElementsByTagName( 'head' )[0].appendChild( styleElem );
- }
- /*** REQUEST ***/
- async function request() {
- const response = await requestPages();
- return await processPages(response);
- }
- async function requestPages(){
- const request = await fetch(PAGES_URL, {
- 'method' : 'POST',
- 'headers' : HEADERS
- });
- return await request.json();
- }
- async function processPages(response) {
- const links = [];
- for (let i = 1; i <= response.pages.count; i++){
- let link = PAGE_URL.replace('$1', i);
- links.push(link);
- }
- return links;
- }
- /*** RENDER ***/
- function render(links) {
- addCSS('\
- .hack_container { position:fixed; top:0; right:0; bottom:0; left: 0; padding:24px; overflow:auto; z-index:9999; background:white; }\
- .hack_container textarea { width:100%; height:100%; resize:none; }\
- .hack_container_close { position:absolute; top:4px; right: 24px; z-index:2; }\
- ');
- const container = document.createElement('div');
- container.classList.add('hack_container');
- const close = document.createElement('div');
- close.innerText = 'Закрыть';
- close.classList.add('hack_container_close');
- close.addEventListener('click', function(){
- document.body.removeChild(container);
- });
- container.appendChild(close);
- const textarea = document.createElement('textarea');
- textarea.value = links.join('\n');
- container.appendChild(textarea);
- document.body.appendChild(container);
- }
- /*** BOOTSTRAP ***/
- request().then(render);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement