您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Changes the loot you find to be hyperlinks to the wiki
当前为
- // ==UserScript==
- // @name Ghost Trappers Wiki links on Feed
- // @version 0.6
- // @description Changes the loot you find to be hyperlinks to the wiki
- // @author Hazado
- // @match *www.ghost-trappers.com/fb/camp.php*
- // @match *www.ghost-trappers.com/fb/hunt.php*
- // @grant none
- // @namespace https://greasyfork.org/users/149039
- // ==/UserScript==
- function getMatches(string, regex, index) {
- index || (index = 1); // default to the first capturing group
- var matches = [];
- var match;
- while (match = regex.exec(string)) {
- matches.push(match[index]);
- }
- return matches;
- }
- String.prototype.capitalize = function() {
- return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
- };
- for (i = 0; i < document.querySelectorAll('b').length; i++) {
- if (document.querySelectorAll('b')[i].innerHTML.search('^<br>[0-9]+') === 0)
- {
- var matches = getMatches(document.querySelectorAll('b')[i].innerHTML,/<br>[0-9]+(?: x)? ([a-zA-Z -:()ß]*)/g,0);
- var saved = getMatches(document.querySelectorAll('b')[i].innerHTML,/(<br>[0-9]+(?: x)? )[a-zA-Z -:()ß]*/g,0);
- document.querySelectorAll('b')[i].innerHTML = null;
- for (j = 0; j < matches.length; j++) {
- var a = document.createElement('a');
- if (matches[j].replace(/_\(special\)/,'').match(/[A_Z]*\.[0-9]/) !== null) a.innerHTML = saved[j]+'<a href="http://wiki.ghost-trappers.com/index.php/'+matches[j].replace(/ /g,'_').replace(/_-_/,'_').replace(/-/,'/').replace(/Blueprint:_|_\(special\)|Molding_half:_|Schematic:_/,'')+'" target="_blank">'+matches[j]+'</a>';
- else a.innerHTML = saved[j]+'<a href="http://wiki.ghost-trappers.com/index.php/'+matches[j].replace(/ /g,'_').replace(/_-_/,'_').replace(/-/,'/').replace(/Blueprint:_|_\(special\)|Molding_half:_|Schematic:_/,'').capitalize()+'" target="_blank">'+matches[j]+'</a>';
- while(a.firstChild) {
- document.querySelectorAll('b')[i].appendChild(a.firstChild);
- }
- }
- }
- }