Guest User

FA Conglomerator 3.2.1c

a guest
Dec 31st, 2019
1,108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           FA Conglomerator (same page alternate version; FA Modern Theme fix)
  3. // @namespace      http://lulz.net/
  4. // @version        3.2.1c
  5. // @description    Asynchronously extracts all submissions from a FurAffinity gallery or scraps collection and displays them as a list of links replacing the gallery content. A button "Conglomerate" is inserted into the gallery/scraps collection page which activates the script. Additional input boxes allow the specification of the maximum number of concurrent requests used, a request delay time and the number of retries. Install guide, updates, changelog and other scripts @ http://pastebin.com/u/lulzScript
  6. // @include        http*://*.furaffinity.net/gallery/*
  7. // @include        http*://*.furaffinity.net/scraps/*
  8. //
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. //
  12. // ==/UserScript==
  13.  
  14.  
  15. function _GM_getValue(key) {
  16.   return (typeof(GM_getValue) == 'function') ? GM_getValue(key) : undefined;
  17. }
  18.  
  19. //Some constants
  20. //Default is 48 submissions per page. Valid values can be taken from the drop-down box on the gallery page.
  21. var congPerPage = 48;
  22. //Default is up to 10 retries for a page/submission to load.
  23. var congRetries = 10;
  24.  
  25. //Maximum number of concurrent requests. Default is 4.
  26. //Note: Your browser may still generally limit the maximum concurrent requests per server according to its system settings.
  27. var maxConcReq = 4;
  28.  
  29. //The polling times in miliseconds for submission requests and submission list requests.
  30. //Each request will check for an available request slot using this interval.
  31. //This is needed to limit concurrent request to maxConcReq.
  32. //The value of submListPollTime should be lower than submPollTime, to give page loading priority over submission loading.
  33. var submPollTime = 40;
  34. var submListPollTime = 20;
  35.  
  36. //Nummber of miliseconds to wait before a request slot is freed for further request
  37. //Can be used to reduce the stress on the server but links will take longer to conglomerate
  38. var congFreeSlotDelay = 500;
  39.  
  40.  
  41. // Strip 'href' attribute from all links on page, so will not be picked up by batch downloader;
  42. // replicates link functionality via inserting 'onclick' event.
  43. function disableLinks() {
  44.  
  45.   function clickLink(e) {
  46.     var elt = this;
  47.     e.preventDefault();
  48.     elt.href = elt.getAttribute('data-href');
  49.     elt.removeEventListener('click', clickLink, true);
  50.     elt.click();
  51.     setTimeout(function() {
  52.       elt.href = '#'
  53.       elt.addEventListener('click', clickLink, true);
  54.     }, 0);
  55.   }
  56.  
  57.   var links = document.body.getElementsByTagName('a');
  58.   for (var i = 0, j = links.length; i < j; i++) {
  59.     var elt = links[i];
  60.     if (elt.getAttribute('data-href') === null) {
  61.       elt.setAttribute('data-href', elt.href);
  62.       elt.href = '#'
  63.       elt.addEventListener('click', clickLink, true);
  64.     }
  65.   }
  66. }
  67.  
  68.  
  69. //When each request either loaded or gave an error, the rCount should be back at 0.
  70. //Pending downlaods lead to rCount > 0
  71. function checkIfDone()
  72. {
  73.   if (rCount == 0)
  74.     lStatus.innerHTML = '<b> Done!</b>';
  75. }
  76.  
  77. //Frees a used request slot
  78. function freeRequestSlot()
  79. {
  80.   concReq--;
  81. }
  82.  
  83. //Function called when a submission page was successfully loaded.
  84. //req = XMLHttpRequest object of the loaded page
  85. //linkObj = link object within the new link window
  86. function onSubm (req, linkObj)
  87. {
  88.   //Extract download link from submission page
  89.   var submFile_ = req.responseText.match(/< *a *href=\"([^>\"]*)\" *> *Download *< *\/a *>/i);
  90.   if ( submFile_ )
  91.   {
  92.     var wProto = submFile_[1].replace(/^\/\//, faProto[0]);
  93.     //Insert extracted download link into link list
  94.     //Link displayed as text
  95.     linkObj.innerHTML = wProto;
  96.     //Also set the href attribut, to make the link clickable
  97.     linkObj.setAttribute('href', wProto);
  98.   }
  99.  
  100.   //Request finished successfully. Decrease request counter and check if rCount = 0.
  101.   rCount--;
  102.   checkIfDone();
  103.  
  104. }
  105.  
  106. //Function called when a submission page failed to load.
  107. //req = XMLHttpRequest object of the failed page
  108. //linkObj = link object within the new link window
  109. //retry = counter that indicates the current number of retries.
  110. function onSubmErr (req, linkObj, retry)
  111. {
  112.   //Display "Error" in the linklist if the link couldn't be extracted.
  113.   linkObj.innerHTML = '<b>Error (retry = ' + retry + '/' + congRetries + ')</b>';
  114.  
  115.   //Request finished with error. Decrease request counter and check if rCount = 0.
  116.   rCount--;
  117.   checkIfDone();
  118. }
  119.  
  120. //Loads a submission page asynchronously.
  121. //submURL = Full URL of submission.
  122. //linkObj = link object within the new link window
  123. //retry = counter that indicates the current number of retries.
  124. //After [congRetries] failed retries, the function fails.
  125. function getSubm (submURL, linkObj, retry)
  126. {
  127.   //Check for free request slot
  128.   if (concReq < maxConcReq)
  129.   {
  130.     //Reserve request slot
  131.     concReq++;
  132.  
  133.     //Display loading message and retries needed if any.
  134.     if (retry == 0)
  135.       linkObj.innerHTML = '<b>loading...</b>';
  136.     else
  137.       linkObj.innerHTML = '<b>loading...(retry = ' + retry + '/' + congRetries + ')</b>';
  138.  
  139.     var req = new XMLHttpRequest();
  140.     //Prepare request with full URL, containing the desired page number
  141.     req.open('GET', submURL, true);
  142.     //Function to call when loading state of page changes
  143.     req.onreadystatechange = function (evt)
  144.     {
  145.  
  146.       //Check if page was loaded (or not)
  147.       if (req.readyState == 4)
  148.       {
  149.         //Free reserved request slot
  150.         if (congFreeSlotDelay > 0)
  151.           setTimeout (freeRequestSlot, congFreeSlotDelay);
  152.         else
  153.           freeRequestSlot();
  154.  
  155.         if (req.status == 200)
  156.         {
  157.           //Page was sucessfully loaded
  158.           //Call handler for successful requests.
  159.           onSubm (req, linkObj);
  160.         }
  161.         else
  162.         {
  163.           //If page failed to load, retry up to [congRetries] times.
  164.           if ( retry < congRetries )
  165.           {
  166.             linkObj.innerHTML = 'waiting...[queued for retry ' + (retry+1) + '/' + congRetries + ']'
  167.             //The retry is done with setTimeout, instead of calling getSubm directly.
  168.             //This will prevent multiple recursive calls for each retry
  169.             setTimeout (getSubm, 0, submURL, linkObj, retry+1);
  170.           }
  171.           else
  172.           {
  173.             //Page could not be loaded even after retrying
  174.             //Call error handler.
  175.             onSubmErr (req, linkObj, retry);
  176.           }
  177.         }
  178.       }
  179.     };
  180.  
  181.     //Sends request and starts loading of the page.
  182.     req.send(null);
  183.   }
  184.   else
  185.     //If no request slot is available, poll for free request slot by calling this request again after a delay of [submPollTime] miliseconds.
  186.     setTimeout (getSubm, submPollTime, submURL, linkObj, retry)
  187. }
  188.  
  189. //Function called when a submission list page was successfully loaded.
  190. //req = XMLHttpRequest object of the loaded page
  191. //no = number of loaded page
  192. //retry = counter that indicates the current number of retries.
  193. function onSubmList (req, no, retry)
  194. {
  195.   //Extract all submission links
  196.   var rawSubmLinks = req.responseText.match(/<a href=\"\/view\/\d+\/\">/gi);
  197.  
  198.   //Continue as long as there are submission links found
  199.   //An empty page indicates the end of a gallery/scraps collection
  200.   if ( rawSubmLinks )
  201.   {
  202.     //Display page number
  203.     var div = document.createElement('div');
  204.  
  205.     //Display page number an retries needed if any.
  206.     if (retry == 0)
  207.       div.innerHTML = '</br></br><b>Page ' + no + '</b></br></br>';
  208.     else
  209.       div.innerHTML = '</br></br><b>Page ' + no + ' (retry = ' + retry + '/' + congRetries + ')</b></br></br>';
  210.  
  211.     congLinkDiv.insertBefore(div, null);
  212.  
  213.     //Iterate through all found links.
  214.     for (var i=0; i < rawSubmLinks.length; i++)
  215.     {
  216.       //Extract actual link from list of matched links
  217.       var submLink = rawSubmLinks[i].match(/<a href=\"\/view\/(\d+)\/\">/);
  218.       if ( submLink )
  219.       {
  220.         //Make full URL of submission page from link.
  221.         var submURL = faBaseURL + '/view/' + submLink[1] + '/';
  222.  
  223.         //Add new line for submission in link window and set status to "loading..."
  224.         var div = document.createElement('div');
  225.         div.innerHTML = '<b>' + sCount + ': </b>';
  226.         var linkObj = document.createElement('a');
  227.         linkObj.innerHTML = 'waiting...';
  228.         linkObj.setAttribute('target', '_blank');
  229.         div.insertBefore(linkObj, null);
  230.         congLinkDiv.insertBefore(div, null);
  231.  
  232.         //New request. Increase request counter.
  233.         rCount++;
  234.         getSubm (submURL, linkObj, 0);
  235.  
  236.         //Increase submission counter
  237.         sCount++;
  238.  
  239.       }
  240.     }
  241.  
  242.     //New request. Increase request counter.
  243.     rCount++;
  244.     //Load next submission list page
  245.     getSubmList (submBaseURL, no+1, congPerPage, 0);
  246.   }
  247.   else
  248.   {
  249.     //There are no more pages. Display message.
  250.     var div = document.createElement('div');
  251.     div.innerHTML = '</br></br><b>No more pages!</b>';
  252.     congLinkDiv.insertBefore(div, null);
  253.   }
  254.  
  255.   //Request finished successfully. Decrease request counter and check if rCount = 0.
  256.   rCount--;
  257.   checkIfDone();
  258.  
  259. }
  260.  
  261. //Function called when a submission list page failed to load.
  262. //req = XMLHttpRequest object of the failed page
  263. //no = number of loaded page
  264. //retry = counter that indicates the current number of retries.
  265. function onSubmListErr (req, no, retry)
  266. {
  267.   //Page could not be loaded. Display Error message.
  268.   var div = document.createElement('div');
  269.   div.innerHTML = '</br></br><b>Error - cannot load page ' + no + ' (retry = ' + retry + '/' + congRetries + ')!<br/>Further conglomeration stoppped.</b><br/>';
  270.   congLinkDiv.insertBefore(div, null);
  271.  
  272.   //Request finished with error. Decrease request counter and check if rCount = 0.
  273.   rCount--;
  274.   checkIfDone();
  275. }
  276.  
  277. //Loads a submission list page from the gallery/scraps collection asynchronously.
  278. //baseURL = Base URL of gallery/scraps collection page.
  279. //no = Nummer of list page to load
  280. //perpage = submissions per page {24, 36, 48, 60}
  281. //retry = counter that indicates the current number of retries.
  282. //After [congRetries] failed retries, the function fails.
  283. function getSubmList (baseURL, no, perpage, retry)
  284. {
  285.   //Check for free request slot
  286.   if (concReq < maxConcReq)
  287.   {
  288.     //Reserve request slot
  289.     concReq++;
  290.  
  291.     var req = new XMLHttpRequest();
  292.     //Prepare request with full URL, containing the desired page number
  293.     req.open('POST', baseURL + no, true);
  294.     //Set additional request header
  295.     req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  296.  
  297.     //Function to call when loading state of page changes
  298.     req.onreadystatechange = function (evt)
  299.     {
  300.       //Check if page was loaded (or not)
  301.       if (req.readyState == 4)
  302.       {
  303.         //Free reserved request slot
  304.         if (congFreeSlotDelay > 0)
  305.           setTimeout (freeRequestSlot, congFreeSlotDelay);
  306.         else
  307.           freeRequestSlot();
  308.  
  309.         if (req.status == 200)
  310.         {
  311.           //Page was sucessfully loaded
  312.           //Call handler for successful requests.
  313.           onSubmList (req, no, retry);
  314.         }
  315.         else
  316.         {
  317.           //If page failed to load, retry up to [congRetries] times.
  318.           if ( retry < congRetries )
  319.             //The retry is done with setTimeout, instead of calling getSubmList directly.
  320.             //This will prevent multiple recursive calls for each retry and therefore save stack resources.
  321.             setTimeout (getSubmList, 0, baseURL, no, perpage, retry+1);
  322.           else
  323.           {
  324.             //Page could not be loaded even after retrying
  325.             //Call error handler.
  326.             onSubmListErr (req, no, retry);
  327.           }
  328.         }
  329.       }
  330.     };
  331.  
  332.     //Sends request and starts loading of the page.
  333.     req.send('perpage=' + perpage);
  334.   }
  335.   else
  336.     //If no request slot is available, poll for free request slot by calling this request again after a delay of [submListPollTime] miliseconds.
  337.     setTimeout(getSubmList, submListPollTime, baseURL, no, perpage, retry);
  338. }
  339.  
  340. //Global variables:
  341.  
  342. //Holds the object of the drop-down box containing the selected number of submissions per page
  343. var submPerPage;
  344. //Base URL of FA, including protocol and subdomain
  345. var faBaseURL;
  346. //Base URL of gallery/scraps
  347. var submBaseURL;
  348. //Reference to new link window
  349. var congLinkDiv;
  350. //Counter for submission index
  351. var sCount;
  352. //Name of FA user whose galery/scraps are being conglomerated
  353. var faUsername;
  354. //Source of submission ("gallery" or "scraps")
  355. var submSrc;
  356. //Reference to status message in link window
  357. var lStatus;
  358. //Request counter. Used to determine when all submissions are loaded.
  359. var rCount;
  360. //Protocol http or https
  361. var faProto;
  362. //Counter for concurrent connections
  363. var concReq;
  364.  
  365. //Main script function. Called when conglomerator button is clicked
  366. function congStart(e)
  367. {
  368.   //Prevents the form's default action for a button
  369.   e.preventDefault();
  370.  
  371.   //Get FA base URL (including protocol and subdomain); gallery/scraps base URL; submission source and username
  372.   var baseURLs = document.location.href.match(/((.*furaffinity\.net)\/(gallery|scraps)\/([^\/]*))(?:\/|)/);
  373.   if ( baseURLs )
  374.   {
  375.     submBaseURL = baseURLs[1] + '/'; //Submission base URL
  376.     faBaseURL = baseURLs[2];         //FA base URL
  377.     submSrc = baseURLs[3];           //submission source
  378.     faUsername = baseURLs[4];        //FA username
  379.  
  380.     faProto = document.location.href.match(/(.*):\/\//);
  381.  
  382.     disableLinks();
  383.    
  384.     // Clear submission space to replace with conglomerated links:
  385.     var subList = document.body.getElementsByClassName('submission-list');
  386.     subList = subList.length && subList[0];
  387.    
  388.     if ( subList )
  389.     {
  390.       var subGallery = subList.getElementsByTagName('section');
  391.       subGallery = subGallery.length && subGallery[0];
  392.      
  393.       if (subGallery) {
  394.         subGallery.style.display = 'none';
  395.        
  396.         congLinkDiv = document.createElement('div');
  397.         subList.insertBefore(congLinkDiv, subGallery);
  398.  
  399.         //Set title of new window
  400.         var span = document.createElement('span');
  401.         span.innerHTML = '<b>List of ' + faUsername + '\'s ' + submSrc + ':</b>';
  402.         congLinkDiv.insertBefore(span, null);
  403.  
  404.         //Add status message to link Window
  405.         lStatus = document.createElement('span');
  406.         lStatus.innerHTML = '<b> Loading...</b>';
  407.         congLinkDiv.insertBefore(lStatus, null);
  408.  
  409.         //Reset submission-, request and connection counter
  410.         sCount = 1;
  411.         rCount = 1;
  412.         concReq = 0;
  413.  
  414.         //Set maximum concurrent requests according to the input field
  415.         maxConcReq = parseInt(congMCRInput.value, 10);
  416.  
  417.         //Set free slot delay according to the input field
  418.         congFreeSlotDelay = parseInt(congFSDInput.value, 10);
  419.  
  420.         //Set retries according to the input field
  421.         congRetries = parseInt(congRetInput.value, 10);
  422.  
  423.         //Set number sumbissions per page using the selected value of the drop-down box if it is valid, otherwise uses default value
  424.         if (submPerPage)
  425.         {
  426.           var congPerPage_ = parseInt(submPerPage.value, 10);
  427.           if (!isNaN(congPerPage))
  428.             congPerPage = congPerPage_;
  429.         }
  430.  
  431.         //At this point faBaseURL and submBaseURL both matched correctly.
  432.         //Load first submission list page
  433.         getSubmList (submBaseURL, 1, congPerPage, 0, 0);
  434.       }
  435.     }
  436.   }
  437. }
  438.  
  439. function insertButton()
  440. {  
  441.   //Find location of gallery control buttons
  442.   var browsebar;
  443.  
  444.   if (!isModern) {
  445.     browsebar = document.getElementsByClassName('page-options');
  446.   } else {
  447.     browsebar = document.querySelectorAll('div.submission-list');    
  448.     browsebar[0].style.textAlign = 'center';    
  449.   }
  450.  
  451.  
  452.  
  453.   //If found, insert conglomerator button
  454.   if ( browsebar.length >= 1 )
  455.   {
  456.     var bParent = browsebar[0];
  457.    
  458.     if (isModern) {      
  459.       bParent.insertBefore(congTbl, bParent.firstChild);
  460.       bParent.insertBefore(document.createElement('br'), congTbl);  
  461.     } else {
  462.       bParent.insertBefore(congButton, bParent.firstChild);
  463.       bParent.insertBefore(congInputSpan, congButton.nextSibling);
  464.       bParent.insertBefore(document.createElement('br'), congInputSpan.nextSibling);  
  465.       bParent.insertBefore(document.createElement('br'), congInputSpan.nextSibling);
  466.     }    
  467.  
  468.     //Find drop-down box containing the valid values for the number of submissions per page
  469.     var submPerPage_ = document.getElementsByName('perpage');
  470.     if (submPerPage_.length > 0)
  471.     {
  472.       submPerPage = submPerPage_[0];
  473.       var submPerPageTitle = 'NOTE: This input box is part of the original webpage and lets you set the number of submissions you can view per page.\nThe conglomerator will also use this value for the number of submissions per page it will request from the server.';
  474.  
  475.       //Insert oder add tooltip text to original input field
  476.       if (!submPerPage.title)
  477.         submPerPage.title = submPerPageTitle;
  478.       else
  479.         submPerPage.title = submPerPage.title + '\n\n' + submPerPageTitle;
  480.     }
  481.  
  482.     buttonInserted = true;
  483.   }
  484. }
  485.  
  486. // Flag that is later set to true if button was inserted.
  487. var buttonInserted = false;
  488.  
  489. // Signal whether using the 'modern' FA theme.
  490. var isModern = false;
  491.  
  492. if (document.getElementsByClassName('page-options').length <= 0) {
  493.   if (document.querySelectorAll('div.submission-list').length > 0) isModern = true;
  494. }
  495.  
  496.  
  497. function onCongMCRInputChange(e)
  498. {
  499.   GM_setValue ('maxConcReq', congMCRInput.value);
  500. }
  501.  
  502. //Create button for conglomerator script
  503. var congButton = document.createElement('button');
  504. //Set button styles/attributes
  505. congButton.setAttribute('class', 'button');
  506. congButton.innerHTML = 'Conglomerate';
  507. congButton.style.marginRight = '10px';
  508. if (isModern) congButton.style.marginLeft = '5px';
  509. congButton.title = 'Start conglomeration';
  510.  
  511. //Set function to call on a click
  512. congButton.addEventListener ('click', congStart, false);
  513.  
  514.  
  515. //Create and insert text label
  516. var congInputLabel1 = document.createElement('span');
  517. congInputLabel1.innerHTML = 'Concurrent requests:';
  518.  
  519.  
  520. //Create input field for maximum number of concurrent requests
  521. var congMCRInput = document.createElement('input');
  522.  
  523.  
  524. //Create and insert text label
  525. var congInputLabel2 = document.createElement('span');
  526. congInputLabel2.innerHTML = 'Request delay [ms]:';
  527.  
  528. //Create input field for request delay
  529. var congFSDInput = document.createElement('input');
  530.  
  531. var congInputLabel3 = document.createElement('span');
  532. congInputLabel3.innerHTML = 'Retries:';
  533.  
  534.  
  535. //Create input field for number of retries
  536. var congRetInput = document.createElement('input');
  537.  
  538.  
  539. // Create span to group all conglomerator input fields (classic theme only)
  540. if (!isModern) {
  541.   var congInputSpan = document.createElement('span');
  542.  
  543.   congInputSpan.insertBefore (congInputLabel1, null);
  544.   congInputSpan.insertBefore (congMCRInput, null);
  545.   congInputSpan.insertBefore (congInputLabel2, null);
  546.   congInputSpan.insertBefore (congFSDInput, null);
  547.   congInputSpan.insertBefore (congInputLabel3, null);
  548.   congInputSpan.insertBefore (congRetInput, null);
  549. // Otherwise, insert into a table:
  550. } else {
  551.   var congTbl, congTr, congTd;
  552.   congTbl = document.createElement('table');
  553.   congTbl.style.textAlign = 'left';
  554.   congTbl.style.display = 'inline-block';
  555.  
  556.   congTr = document.createElement('tr');
  557.   congTbl.appendChild(congTr);
  558.  
  559.   congTd = document.createElement('td');  
  560.   congTr.appendChild(congTd);
  561.   congTd = document.createElement('td');
  562.   congTd.appendChild(congButton);
  563.   congTr.appendChild(congTd);
  564.  
  565.   congTr = document.createElement('tr');
  566.   congTbl.appendChild(congTr);
  567.  
  568.   congTd = document.createElement('td');  
  569.   congTd.appendChild(congInputLabel1);
  570.   congTr.appendChild(congTd);
  571.   congTd = document.createElement('td');
  572.   congTd.appendChild(congMCRInput);
  573.   congTr.appendChild(congTd);
  574.  
  575.   congTr = document.createElement('tr');
  576.   congTbl.appendChild(congTr);
  577.  
  578.   congTd = document.createElement('td');  
  579.   congTd.appendChild(congInputLabel2);
  580.   congTr.appendChild(congTd);
  581.   congTd = document.createElement('td');
  582.   congTd.appendChild(congFSDInput);
  583.   congTr.appendChild(congTd);
  584.  
  585.   congTr = document.createElement('tr');
  586.   congTbl.appendChild(congTr);
  587.  
  588.   congTd = document.createElement('td');  
  589.   congTd.appendChild(congInputLabel3);
  590.   congTr.appendChild(congTd);
  591.   congTd = document.createElement('td');
  592.   congTd.appendChild(congRetInput);
  593.   congTr.appendChild(congTd);  
  594. }
  595.  
  596.  
  597. //Set input styles/attributes
  598. congMCRInput.setAttribute('class', 'button');
  599. congMCRInput.setAttribute ('type', 'number');
  600. congMCRInput.setAttribute ('size', '3');
  601. congMCRInput.setAttribute ('min', '1');
  602. congMCRInput.style.width = '30px';
  603. congMCRInput.style.marginLeft = '5px';
  604. congMCRInput.style.marginRight = '10px';
  605. congMCRInput.title = 'Maximum number of concurrent requests made to the server.\nIf this number is too high it might trigger request restrictions and timeouts on the server side, leading to high numbers of retries and possibly incomplete conglomeration.';
  606.  
  607. //Load last used value from storage
  608. var maxConcReq_ = _GM_getValue('maxConcReq');
  609. //If value is valid, set as initial value
  610. if (maxConcReq_)
  611.   congMCRInput.value = maxConcReq_;
  612. else
  613.   congMCRInput.value = maxConcReq;
  614.  
  615. congMCRInput.addEventListener ('change', onCongMCRInputChange, false);
  616.  
  617.  
  618. function onCongFSDInputChange(e)
  619. {
  620.   GM_setValue ('congFreeSlotDelay', congFSDInput.value);
  621. }
  622.  
  623. //Set input styles/attributes
  624. congFSDInput.setAttribute('class', 'button');
  625. congFSDInput.setAttribute ('type', 'number');
  626. congFSDInput.setAttribute ('size', '3');
  627. congFSDInput.setAttribute ('min', '0');
  628. congFSDInput.style.width = '50px';
  629. congFSDInput.style.marginLeft = '5px';
  630. congFSDInput.style.marginRight = '10px';
  631. congFSDInput.title = 'Number of milliseconds [ms] to wait before a request slot is freed for further requests.\nIncreasing this number can reduce the stress on the server but conglomeration will take longer';
  632.  
  633.  
  634. //Load last used value from storage
  635. var congFreeSlotDelay_ = _GM_getValue ('congFreeSlotDelay');
  636. //If value is valid, set as initial value
  637. if (congFreeSlotDelay_)
  638.   congFSDInput.value = congFreeSlotDelay_;
  639. else
  640.   congFSDInput.value = congFreeSlotDelay;
  641.  
  642. congFSDInput.addEventListener ('change', onCongFSDInputChange, false);
  643.  
  644.  
  645. function onCongRetInputChange(e)
  646. {
  647.   GM_setValue ('congRetries', congRetInput.value);
  648. }
  649.  
  650. //Set input styles/attributes
  651. congRetInput.setAttribute('class', 'button');
  652. congRetInput.setAttribute ('type', 'number');
  653. congRetInput.setAttribute ('size', '3');
  654. congRetInput.setAttribute ('min', '0');
  655. congRetInput.style.width = (isModern) ? '40px' : '30px';
  656. congRetInput.style.marginLeft = '5px';
  657. congRetInput.title = 'The number of retries for a single request if an error occurs.\nIf there are many requests with a high number of retries in the conglomerator window, try to decreas the number of concurrent requests and/or increase the request delay.';
  658.  
  659. //Load last used value from storage
  660. var congRetries_ = _GM_getValue ('congRetries');
  661. //If value is valid, set as initial value
  662. if (congRetries_)
  663.   congRetInput.value = congRetries_;
  664. else
  665.   congRetInput.value = congRetries;
  666.  
  667. congRetInput.addEventListener ('change', onCongRetInputChange, false);
  668.  
  669.  
  670. //Try to insert button into page if page is already available at this time
  671. insertButton();
  672.  
  673. //Function onDCL is called when DOM tree has completely been loaded.
  674. //This is the safest way to start a script.
  675. document.addEventListener ('DOMContentLoaded',
  676.   function onDCL(e)
  677.   {
  678.     //If the button wasn't inserted before because the page wasn't
  679.     //available at that time, it will be inserted now.
  680.     if ( !buttonInserted )
  681.       insertButton();
  682.  
  683.   }, false
  684. );
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×