More UI

The first version to The GT UI+

当前为 2015-07-28 提交的版本,查看 最新版本

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