Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. // ==UserScript==
  2. // @name LoL Skin Installer Integration +LGG +LC
  3. // @author LGG
  4. // @namespace LoLSIULGGLC
  5. // @icon http://img856.imageshack.us/img856/7456/unled2lq.jpg
  6. // @description Re-works links in League craft to auto work with SIU+LGG
  7. // @version 0.6 (25 March 2012)
  8. // @license GPL 2.0
  9. // @include http://leaguecraft.com/skins/*
  10. // @exclude http://leaguecraft.com/skins/download/*
  11. // @include http://www.leaguecraft.com/skins/*
  12. // @exclude http://www.leaguecraft.com/skins/download/*
  13. // ==/UserScript==
  14. var debug = 0;
  15. var wait = 200;
  16.  
  17. if (debug > 2) {
  18. my_debug_div = document.createElement('div');
  19. my_debug_div.innerHTML = '<div style="height: 200px; width: 500px; ' +
  20. 'background-color: #330000; z-index: 100; position: fixed;' +
  21. 'padding: 5px; ' +
  22. 'right: 10px; bottom: 10px;" id="my_debug_div">' +
  23. '<p><a id="close_log">Close</a></p>' +
  24. '<textarea style="width: 490px; height: 150px; font-size:75%;" id="lgg_log" readonly>' +
  25. '</textarea>' +
  26. '</div>';
  27.  
  28. document.body.insertBefore(my_debug_div, document.body.firstChild);
  29. document.getElementById('close_log').addEventListener("click", toggle_lgg_log, true);
  30. }
  31.  
  32. if (debug > 0) lgg_log('Current Location: ' + document.location);
  33. setTimeout(init, wait);
  34. function init() {
  35. //var html_tag = evaluate_xpath('.//html');
  36. lgg_log("page loaded");
  37.  
  38. var downloadLinks = evaluate_xpath('.//a[ @href[contains(.,"skins/download")] ]');
  39. var i = 0;
  40. if (downloadLinks.snapshotLength < 1) return;
  41. var downloadLink = downloadLinks.snapshotItem(i);
  42. var downloadURL = downloadLink.getAttribute("href")
  43. if (debug > 0) lgg_log("Download URL is " + downloadURL);
  44. //var linksToReplace = evaluate_xpath('.//a[ @href[contains(.,"http://forum.leaguecraft.com/index.php?/topic/1700-how-to-install-skins")] and @style[contains(.,"")]]');
  45. //var linkToReplace = linksToReplace.snapshotItem(i);
  46. // <img src="uploads/MMKH/skins/924.jpg" class="example_image" />
  47. var imageBoxs = evaluate_xpath('.//div[ @id[contains(.,"image_container")]]');
  48. var imageBox = imageBoxs.snapshotItem(i);
  49. //x:html/x:body/x:div[2]/x:table/x:tbody/x:tr[4]/x:td[1]/x:div[1]/x:div/x:table/x:tbody/x:tr/x:td/x:table/x:tbody/x:tr[2]/x:td
  50.  
  51. //<meta name="description" content="Riven Skin: Custom Skin created by lordgreggreg. This skin is rated: Good" />
  52.  
  53. var descriptionBoxs = evaluate_xpath('.//meta[ @name[contains(.,"description")]]');
  54. var descriptionBox = descriptionBoxs.snapshotItem(i);
  55. var nameDesc = descriptionBox.getAttribute("content");
  56.  
  57. var add = 2;
  58. if (debug > 2) add = 3;
  59. //x:html/x:body/x:div[2]/x:table/x:tbody/x:tr[4]/x:td[1]/x:div[2]/x:div
  60. //x:html/x:body/x:div[3]/x:table/x:tbody/x:tr[5]/x:td[1]/x:div/x:div/x:p
  61. //x:html/x:body/x:div[3]/x:table/x:tbody/x:tr[6]/x:td[1]/x:div/x:div/x:p
  62. var infoBoxs = evaluate_xpath('.//p[ @id[contains(.,"description")]]');
  63.  
  64. //evaluate_xpath('.//body/div[' + add + ']/table/tbody/tr[6]/td[1]/div/div/p');
  65.  
  66. var SIURL = "skininstallerultimatelgg://";
  67.  
  68. //-----------URL------------
  69. //http://leaguecraft.com/download/skin/924
  70. //http://leaguecraft.com/skins/download/924-ancient-guardian-nasus-by-mmkh
  71. //var skinNumber = downloadURL.substring(downloadURL.lastIndexOf("/") + 1, downloadURL.indexOf("-"));
  72. // /skins/download/?id=6701
  73. var skinNumber = downloadURL.substring(downloadURL.lastIndexOf("/") + 5);
  74.  
  75. var directURL = 'http://leaguecraft.com/skins/download/?id=' + skinNumber;
  76. if (debug > 0) lgg_log("URL is " + directURL);
  77. SIURL += '[param]url[value]' + directURL;
  78. //----------NAME-----------
  79. //<title>Ancient Guardian Nasus (by MMKH) by MMKH :: Nasus, the Curator of the Sands :: Custom Skin :: Leaguecraft</title>
  80. //var end = document.title.indexOf("::");
  81. //if (end == -1) end = document.title.indexOf("|");
  82. var title = document.title; //.substring(0, end);
  83. //remove stuff in parens
  84. title = title.replace(/\(.*\)/, '').replace(/\[.*\]/, '').replace(/\{.*\}/, '').replace(/\|/g, "-");
  85.  
  86. var name = title.replace(/^\s+|\s+$/g, '');
  87. if (debug > 0) lgg_log("Name is " + name);
  88. SIURL += '[param]name[value]' + name;
  89. //-------------AUTHOR-----
  90. var author = nameDesc.substring(nameDesc.lastIndexOf(" by") + 3, nameDesc.lastIndexOf(".")).replace(/^\s+|\s+$/g, '').replace(/\|/g, "-");
  91. if (debug > 0) lgg_log("Author is " + author);
  92. SIURL += '[param]author[value]' + author;
  93. //------------IMAGE PREVIEW------------
  94. var imgs = imageBox.getElementsByTagName("img");
  95. var imageURL = /*'http://leaguecraft.com/' + */imgs[0].src;
  96. if (debug > 0) lgg_log("Image is " + imageURL);
  97. SIURL += '[param]preview[value]' + imageURL;
  98. //------------INFO----------
  99. if (infoBoxs.snapshotLength > 0) {
  100. var infoBox = infoBoxs.snapshotItem(i);
  101.  
  102. var theInfo = infoBox.innerHTML.substring(infoBox.innerHTML.indexOf("</div-->") + 8).replace(/<br>/g, "[New Line]").replace(/:/g, "[Colon]").replace(/"/g, "'").replace(/\|/g, "-").replace(/^\s+|\s+$/g, '');
  103. if (debug > 3) lgg_log("Info is " + theInfo);
  104. SIURL += '[param]info[value]' + theInfo;
  105. }
  106.  
  107.  
  108. //----------LINK MAKE------
  109. var my_link = document.createElement('a');
  110. my_link.innerHTML = '<div class="button" style="background-color:maroon; width:119p">' +
  111. '<a href="' + SIURL + '" style="color: rgb(255,255,200); width:119px; text-decoration: none; text-align: top;">' +
  112. // '<div id="5a4b1e24ab14c7a56d2abde5febf69ac" class="clickable rounded_10px action_button" style="font-size: 17px;">' +
  113. '<img src="http://siu-lgg.googlecode.com/hg/instalwithsiu.png" width="119" height="25" style="background-color:maroon;width:119px"> &nbsp; ' +
  114. // ' </div>' +
  115. ' </a></div>';
  116.  
  117. //linkToReplace.parentNode.
  118. downloadLink.parentNode.parentNode.insertBefore(my_link, downloadLink.parentNode);
  119.  
  120. //document.body.insertBefore(my_link, document.body.firstChild);
  121.  
  122. ////linkToReplace.innerHTML = '<a href="' + SIURL + '" style="color: rgb(255,255,200); text-decoration: none;">' + ' </a>';
  123.  
  124. //linkToReplace.innerHTML = '<a id="siuLink"; style="color:#000000"; href="'+downloadURL+'">GET @ @</a>';
  125.  
  126.  
  127.  
  128. }
  129.  
  130. function toggle_lgg_log() {
  131. var lgg_log = document.getElementById('my_debug_div');
  132. if (lgg_log.style.display != "none") {
  133. lgg_log.style.display = "none";
  134. } else {
  135. lgg_log.style.display = "block";
  136. }
  137. }
  138. function contains(a, obj) {
  139. for (var i = 0; i < a.length; i++) {
  140. if (a[i] === obj) {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. function removeByElement(arrayName, arrayElement) {
  147. for (var i = 0; i < arrayName.length; i++) {
  148. if (arrayName[i] == arrayElement)
  149. arrayName.splice(i, 1);
  150. }
  151. }
  152. function evaluate_xpath(xpath_query) {
  153. if (debug >= 2) lgg_log(xpath_query);
  154. var nodes = document.evaluate(xpath_query, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  155. if (debug >= 1) lgg_log('nodes returned: ' + nodes.snapshotLength);
  156.  
  157. return nodes;
  158. }
  159.  
  160. function lgg_log(log_string) {
  161. if (debug > 2) {
  162. var logspace = document.getElementById('lgg_log');
  163. logspace.value += log_string + "\n";
  164. logspace.scrollTop = logspace.scrollHeight;
  165. }
  166.  
  167. GM_log(log_string);
  168. }
  169.  
  170. function lgg_log_return(return_value) {
  171. if (return_value > 0) {
  172. lgg_log("Log successfully submitted. Bytes transferred: " + return_value);
  173. } else {
  174. lgg_log("Log could not be submitted. Returned: " + return_value);
  175. }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement