Attack links on faction page - Lynx fork

On faction member list page it replaces the first cell contents with hyperlink to attack loader

  1. // ==UserScript==
  2. // @name Attack links on faction page - Lynx fork
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description On faction member list page it replaces the first cell contents with hyperlink to attack loader
  6. // @author Stephen Lynx
  7. // @match https://www.torn.com/factions.php?step=profile&ID=*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com
  9. // @run-at document-body
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.  
  15. 'use strict';
  16. let uniqueid = 1;
  17.  
  18. var observer = new MutationObserver(function(mutationList, observer) {
  19. mutationList
  20. .forEach(function(event) {
  21.  
  22. if (event.addedNodes.length && event.target.className === 'table-row') {
  23.  
  24. let targetCell = event.target.getElementsByClassName('tt-member-index')[0];
  25.  
  26. let attackLoaderUrl = event.target.getElementsByTagName('a')[1].href.replace('/profiles.php?XID=', '/loader.php?sid=attack&user2ID=');
  27.  
  28. let newLinkContent = '<ul class="big svg" style="display: inline-block;"><li id="icon13_custom_'
  29. + (uniqueid++) + '" class="iconShow" style="margin-bottom: 0px;"><a href="' + attackLoaderUrl + '" target="_blank"></a></li></ul>';
  30.  
  31. targetCell.classList.add('icons');
  32. targetCell.innerHTML = newLinkContent ;
  33. }
  34.  
  35. });
  36.  
  37. });
  38.  
  39. observer.observe(document.getElementsByTagName('body')[0], {
  40. childList : true,
  41. subtree : true
  42. });
  43.  
  44. })();