More UI

The first version to The GT UI+

当前为 2015-08-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name More UI
  3. // @namespace http://use.i.E.your.homepage/
  4. // @version 0.3.1
  5. // @description The first version to The GT UI+
  6. // @match http://www.ghost-trappers.com/fb/camp.php*
  7. // @match http://www.ghost-trappers.com/fb/hunt.php*
  8. // @copyright 2015+, GTNoAPI
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11.  
  12. getSpecialItems();
  13. getCompanionExpAndLike();
  14. function getSpecialItems(){
  15. GM_xmlhttpRequest({
  16. method: 'GET',
  17. url: 'http://www.ghost-trappers.com/fb/setup.php?type=special',
  18. headers: {
  19. "Accept": "text/html",
  20. "Pragma": "no-cache",
  21. "Cache-Control": "no-cache"
  22. },
  23. onload: function(rD) {
  24. var text = rD.responseText;
  25.  
  26. var result = text.match(/<div class="itemHeadline">[A-Za-z0-9'`._%+-\s]+/ig);
  27.  
  28. for(var x = 0; x< result.length; x++){
  29. result[x] = result[x].substr(result[x].indexOf('>')+1, result[x].lastIndexOf(' '));
  30. result[x] = result[x].trim();
  31. }
  32.  
  33. getAyumiShopItems(result);
  34. }
  35. });
  36. };
  37.  
  38. function getAyumiShopItems(itemsInInventory){
  39. GM_xmlhttpRequest({
  40. method: 'GET',
  41. url: 'http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=shop&filterItemType=souvenir_set',
  42. headers: {
  43. "Accept": "text/html",
  44. "Pragma": "no-cache",
  45. "Cache-Control": "no-cache"
  46. },
  47. onload: function(rD) {
  48. var text = rD.responseText;
  49. var itemRGX = text.match(/<div class="itemInfo">(\n(.*?))*.?(<div class="seperatorLine">)/ig);
  50. var itemsHolder = [];
  51. for(var x = 0; x < itemRGX.length; x++){
  52. var rgx = itemRGX[x];
  53. var itemNameRGX = rgx.match(/<div class="itemHeadline">\n*.*<\/div>|<div class="itemSpecialText">[A-Za-z0-9'`._%+-\s]+/ig);
  54. var itemCostRGX = rgx.match(/<div class="itemCurrency">(\n(.*?)<\/div>)*/ig);
  55. var itemName = itemNameRGX[0].match(/\s[A-Z0-9.-_\s]*?</ig);
  56. var itemName = itemName[0].substr(1, itemName[0].length-2);
  57.  
  58. var item;
  59. if(itemsInInventory.indexOf(itemName) == -1){
  60. item = new Item(itemName);
  61. for(var y = 0; y < itemCostRGX.length; y++){
  62. var currency_price = itemCostRGX[y].match(/"PRICE - in(.*?)"|<div class="itemPrice">(.*?)<\/div>/ig);
  63. var currency = currency_price[0].substr(currency_price[0].indexOf('In')+3);
  64. currency = currency.substr(0,currency.length-1);
  65. if(currency == 'Great British Pounds, that goes without saying'){
  66. currency = "GBP"
  67. }
  68. var price = currency_price[1].match(/>[0-9,]*?</ig);
  69. price = price[0].substr(1,price[0].length-2);
  70. try{
  71. price = parseInt(price.replace(/,/ig,''));
  72. }
  73. catch(err)
  74. {
  75. console.log('error parse price');
  76. }
  77. item.setCurrency(currency, price);
  78. }
  79. itemsHolder.push(item);
  80. }
  81. }
  82.  
  83. constract_Table(itemsHolder);
  84. }
  85. });
  86. }
  87.  
  88. function insertCommas(string,text){
  89. var result = text.toString();
  90. if (result.length > 3){
  91. for(var x = result.length-3; x>0; x-=3){
  92. result = result.substring(0, x) + string + result.substring(x, result.length);
  93. }
  94. }
  95.  
  96. return result;
  97. }
  98.  
  99. function constract_Table(array){
  100.  
  101. $('<div class="UserSricpt_container"></div>').appendTo('#header');
  102. $('<div class="souvenirs_container"></div>').appendTo('.UserSricpt_container');
  103. var container = $('.souvenirs_container');
  104. $('.UserSricpt_container').css('position','absolute');
  105. $('.UserSricpt_container').css('top','133%');
  106. $('.UserSricpt_container').css('left','-45%');
  107. $('.UserSricpt_container').css('color','#fff');
  108. for(var x = 0; x < array.length; x++){
  109. $('<a href="http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=shop&filterItemType=souvenir_set" class="custom-item" id="item-'+x+'"></a>')
  110. .append($('<div class="itemName"></div>').html(array[x].getName()))
  111. .append($('<div class="itemCost"></div>').css('display', 'table'))
  112. .appendTo(container);
  113. var key = null;
  114. for(key in array[x].getItemCost())
  115. {
  116. $('#item-'+x).find('.itemCost').append($('<div class="itemCurrencyType"></div>').html('- '+key + " " + array[x].getItemCost()[key]));
  117. }
  118. }
  119. $('.UserSricpt_container').find('.souvenirs_container').css({
  120. 'display':'block',
  121. 'color':'white',
  122. 'position':'relative',
  123. 'padding':'10px',
  124. 'margin-top':'10px',
  125. 'border-radius':'15px',
  126. 'font-size':'14px',
  127. 'width':'607px',
  128. 'z-index': '9999',
  129. 'display': 'none'
  130. });
  131.  
  132.  
  133. container.css({
  134. 'position': 'absolute',
  135. 'left' : '297px',
  136. 'top': '-89px',
  137. 'background-color': 'rgba(0, 0, 0, 0.6)',
  138. 'z-index': '999'
  139. });
  140. $('.UserSricpt_container').prepend($('<button>toggle souvenirs</button>'));
  141. var button = $('.UserSricpt_container').find('button');
  142. button.css({
  143. 'position':'absolute',
  144. 'left':'116px',
  145. 'color': 'white',
  146. 'font-weight':'bold',
  147. 'font-size': '16px',
  148. 'text-shadow': '1px 1px black',
  149. 'padding': '3px 8px',
  150. 'border': '1px solid rgb(206, 174, 7)',
  151. 'border-radius':'5px',
  152. 'background-color': 'gold',
  153. 'z-index': '99999999',
  154. 'min-width':'153px'
  155. });
  156. button[0].addEventListener("click", function(){
  157. if($('.UserSricpt_container').find('.souvenirs_container').css('display') == 'none'){
  158. $('.UserSricpt_container').find('.souvenirs_container').css({
  159. 'display': 'block'
  160. });
  161. }
  162. else{
  163. $('.UserSricpt_container').find('.souvenirs_container').css({
  164. 'display': 'none'
  165. });
  166. }
  167. });
  168. getCurrency(array);
  169. }
  170.  
  171. function insertCommas(string,text){
  172. var result = text.toString();
  173. if (result.length > 3){
  174. for(var x = result.length-3; x>0; x-=3){
  175. result = result.substring(0, x) + string + result.substring(x, result.length);
  176. }
  177. }
  178.  
  179. return result;
  180. }
  181.  
  182. function priceIn(dictionary, array){
  183. var elements = $(".UserSricpt_container").find('.souvenirs_container')[0].childNodes;
  184. console.log(elements);
  185. for(var x= 0; x < elements.length; x++){
  186. var currencyHolder = elements[x];
  187. var children = currencyHolder.childNodes;
  188. children = children[1].childNodes;
  189. var match = 0;
  190. for(var y = 0; y < children.length; y++){
  191. var temp = children[y].innerHTML;
  192. var priceIn = temp.substr(temp.indexOf('-')+2, temp.lastIndexOf(' ')-2).trim();
  193. var price = temp.substr(temp.lastIndexOf(' ')+1);
  194.  
  195. try{
  196. dictionary[priceIn] = parseInt(dictionary[priceIn].replace(/,/ig,''));
  197. }
  198. catch(err)
  199. {
  200. // just skip this error!!!
  201. }
  202. children[y].innerHTML = ' - ' + priceIn +' '+ insertCommas(',',price) + '('+insertCommas(',',dictionary[priceIn])+')';
  203. if(dictionary[priceIn] >= array[x].getCurrency(priceIn)){
  204. if(match == children.length-1){
  205.  
  206. $(".UserSricpt_container").find('.souvenirs_container').find('#item-'+x).css({
  207. 'background-color':'rgba(0, 128, 0, 0.2)',
  208. 'border':'1px solid green',
  209. 'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px green',
  210. '-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px green',
  211. 'display':'block',
  212. 'color':'white',
  213. 'position':'relative',
  214. 'padding':'10px',
  215. 'margin-top':'10px',
  216. 'border-radius':'15px'
  217. });
  218. }
  219. match++;
  220. }
  221. else{
  222. $(".UserSricpt_container").find('.souvenirs_container').find('#item-'+x).css({
  223. 'background-color':'rgba(255, 0, 0, 0.2)',
  224. 'border':'1px solid red',
  225. 'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px red',
  226. '-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px red',
  227. 'display':'block',
  228. 'color':'white',
  229. 'position':'relative',
  230. 'padding':'10px',
  231. 'margin-top':'10px',
  232. 'border-radius':'15px'
  233. });
  234. }
  235. }
  236. }
  237. }
  238.  
  239. function getCurrency(array){
  240. GM_xmlhttpRequest({
  241. method: 'GET',
  242. url: 'http://www.ghost-trappers.com/fb/setup.php?type=currency',
  243. headers: {
  244. "Accept": "text/html",
  245. "Pragma": "no-cache",
  246. "Cache-Control": "no-cache"
  247. },
  248. onload: function(rD) {
  249. var text = rD.responseText;
  250.  
  251. var result = text.match(/<div class="itemInfo">\n*.*<\/div>|<div class="itemSpecialText">[A-Za-z0-9'`._%+-\s]+/ig);
  252. var gbpHolder = document.getElementById('profile_gbp').innerHTML;
  253.  
  254. var dictionary = [];
  255. for(var x = 0; x < result.length-1; x+=2){
  256. var temp = result[x].match(/[A-Z0-9.-_\s]+>/ig);
  257. var key = temp[0].substring(1, temp[0].indexOf('</')).trim();
  258. var value = result[x+1].substring(result[x+1].indexOf('itemSpecialText'), result[x+1].indexOf('.'));
  259. value = value.match(/[0-9]+/ig);
  260. dictionary[key] = parseInt(value);
  261. }
  262. dictionary['GBP'] = gbpHolder;
  263. priceIn(dictionary, array);
  264. }
  265. });
  266. };
  267.  
  268.  
  269. var Item = function(name) {
  270. this.name = name;
  271. this.dictionary = [];
  272. };
  273.  
  274. Item.prototype.getName = function(){
  275. return this.name;
  276. }
  277.  
  278. Item.prototype.setCurrency = function(currency, value){
  279. this.dictionary[currency] = value;
  280. };
  281.  
  282. Item.prototype.getCurrency = function(currency){
  283. return this.dictionary[currency];
  284. };
  285.  
  286. Item.prototype.getItemCost = function(){
  287. return this.dictionary;
  288. }
  289.  
  290. //<<<<>>>
  291. function getCompanionExpAndLike(){
  292. GM_xmlhttpRequest({
  293. method: 'GET',
  294. url: 'http://www.ghost-trappers.com/fb/setup.php?type=companion',
  295. headers: {
  296. "Accept": "text/html",
  297. "Pragma": "no-cache",
  298. "Cache-Control": "no-cache"
  299. },
  300. onload: function(rD) {
  301. var text = rD.responseText;
  302. var rgx = text.match(/<div class="companionFullBar"*.*<\/div>|<div class=companionLikeFullBar*.*<\/div>/ig);
  303. var percent = [];
  304. for(var x= 0; x< rgx.length; x++){
  305. var width = rgx[x].match(/width:[0-9]+/ig);
  306. width = width[0].substr(width[0].indexOf(':')+1);
  307. percent.push((width/200)*100);
  308. }
  309. var companionLVLRGX = text.match(/companion\/level*.*(jpg)/ig);
  310. var companionLVL = companionLVLRGX[0].substr(companionLVLRGX[0].indexOf('_')+1, 1);
  311. var container = $('#petRightContainer');
  312. var likeValue = 0;
  313. if(percent[1]){
  314. likeValue = percent[1];
  315. }
  316. else{
  317. if(companionLVL < 5){
  318. likeValue = 0;
  319. }
  320. else if(companionLVL == 5){
  321. likeValue = 100;
  322. }
  323. }
  324.  
  325. $('<a href="http://www.ghost-trappers.com/fb/setup.php?type=companion" class="exp_like_display"></a>')
  326. .append($('<div class="expDisplay"></div>')
  327. .html(percent[0].toFixed(1) + '%')
  328. .css({
  329. 'float': 'left',
  330. 'padding': '3px',
  331. 'font-weight': 'bold',
  332. 'background-color':'rgba(135, 206, 235, 0.6)',
  333. 'border-radius': '10px',
  334. 'border':'1px solid skyblue',
  335. 'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px skyblue',
  336. '-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px skyblue'
  337. }))
  338. .append($('<div class="likeDisplay"></div>')
  339. .html(likeValue.toFixed(1)+ '%')
  340. .css({
  341. 'float': 'right',
  342. 'padding': '3px',
  343. 'font-weight': 'bold',
  344. 'background-color':'rgba(255, 192, 203, 0.6)',
  345. 'border-radius': '10px',
  346. 'border':'1px solid pink',
  347. 'box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px pink',
  348. '-webkit-box-shadow':'inset 0 1px 1px rgba(0,0,0,.075),0 0 6px pink'
  349. }))
  350. .appendTo(container);
  351. $('.exp_like_display').css({
  352. 'color': 'black',
  353. 'position':'absolute',
  354. 'top': '60px',
  355. 'left': '0px',
  356. 'width': '100%',
  357. 'z-index': '9999'
  358. })
  359. }
  360. });
  361. }
  362.  
  363. //<<<<>>>
  364. exhibition();
  365. function exhibition(){
  366. GM_xmlhttpRequest({
  367. method: 'GET',
  368. url: 'http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=exhibition&currentPage=-2',
  369. headers: {
  370. "Accept": "text/html",
  371. "Pragma": "no-cache",
  372. "Cache-Control": "no-cache"
  373. },
  374. onload: function(rD) {
  375. var text = rD.responseText;
  376.  
  377. $('<div class="UserSricpt_exhibition_container"></div>').appendTo('#header');
  378. $('<div class="exhibition_container"></div>').appendTo('.UserSricpt_exhibition_container');
  379. var container = $('.exhibition_container');
  380. $('.UserSricpt_exhibition_container').css('position','absolute');
  381. $('.UserSricpt_exhibition_container').css('top','150%');
  382. $('.UserSricpt_exhibition_container').css('left','-27%');
  383. $('.UserSricpt_exhibition_container').css('color','#fff');
  384.  
  385. var rgx = text.match(/<div class="souvenirPartsLine " >[\s\nA-Za-z0-9<=>"'\/_.?!]*<\/div>/gi);
  386. var array = [];
  387. var temp = stringRep(text);
  388. for(var x = 0; x< rgx.length; x++){
  389. var rgxImg = rgx[x].match(/src(.*)\w/gi);
  390. array[x] = [];
  391. var asd = temp[x];
  392.  
  393. ($('<a href="http://www.ghost-trappers.com/fb/scotch_ninth_floor.php?page=exhibition&currentPage=-2" class="exhibition-collection" id="exhibition-collection-'+x+'"></a>'))
  394. .appendTo(container);
  395. var item_container = $('#exhibition-collection-'+x);
  396. for(var y=0; y < rgxImg.length-1; y++){
  397. ($('<img '+ rgxImg[y] + '" />').css('width', '10%'))
  398. .appendTo(item_container);
  399. }
  400. }
  401. $('.UserSricpt_exhibition_container').find('.exhibition-collection').css({
  402. 'display':'block',
  403. 'color':'white',
  404. 'position':'relative',
  405. 'padding':'10px',
  406. 'margin-top':'10px',
  407. 'border-radius':'15px',
  408. 'font-size':'14px',
  409. 'width':'607px',
  410. 'z-index': '9999',
  411. 'display': 'none'
  412. });
  413. container.css({
  414. 'position': 'absolute',
  415. 'left' : '183px',
  416. 'top': '-89px',
  417. 'background-color': 'rgba(0, 0, 0, 0.6)',
  418. 'z-index': '999'
  419. });
  420. $('.UserSricpt_exhibition_container').prepend($('<button>toggle exhibition</button>'));
  421. var button = $('.UserSricpt_exhibition_container').find('button');
  422.  
  423. button.css({
  424. 'position':'absolute',
  425. 'left':'0px',
  426. 'color': 'white',
  427. 'font-weight':'bold',
  428. 'font-size': '16px',
  429. 'text-shadow': '1px 1px black',
  430. 'padding': '3px 8px',
  431. 'border': '1px solid rgb(206, 174, 7)',
  432. 'border-radius':'5px',
  433. 'background-color': 'gold',
  434. 'z-index': '99999999',
  435. 'width': '153px'
  436. });
  437.  
  438. button[0].addEventListener("click", function(){
  439.  
  440. if($('.UserSricpt_exhibition_container').find('.exhibition-collection').css('display') == 'none'){
  441. $('.UserSricpt_exhibition_container').find('.exhibition-collection').css({
  442. 'display': 'block'
  443. });
  444. }
  445. else{
  446. $('.UserSricpt_exhibition_container').find('.exhibition-collection').css({
  447. 'display': 'none'
  448. });
  449. }
  450. });
  451. }
  452. });
  453. }
  454.  
  455. function stringRep(text){
  456. var rgx = text.match(/<div class="souvenirSetContainer" >(\n(.*?))*.?(<div class="seperatorLine">)/gi);
  457. var array = [];
  458. for(var x = 0; x < rgx.length; x++){
  459. var name = rgx[x].match(/<div class="souvenirTopLeft">(\n(.*?))*.?(<\/img>)/gi);
  460. name = name[0].substr(name[0].indexOf('souvenirs')+'souvenirs'.length+1, (name[0].lastIndexOf('"')-(name[0].indexOf('souvenirs')+'souvenirs'.length+5)));
  461. if(name.indexOf('04_headline') > -1){
  462. name = name.substr(name.indexOf('04_headline')+'04_headline'.length+1);
  463. }
  464. else if(name.indexOf('headline') > -1){
  465. name = name.substr(name.indexOf('headline')+'headline'.length+1);
  466. }
  467. name = name.replace(/_/ig,' ');
  468. array.push(name);
  469. }
  470. return array;
  471. }