Attack links on enemy list

Adds attack links on enemy list

目前为 2024-10-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         Attack links on enemy list
// @namespace    https://gitgud.com/stephenlynx
// @version      1.1.0
// @description  Adds attack links on enemy list
// @author       Stephen Lynx
// @license      MIT
// @match        https://www.torn.com/blacklist.php
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @run-at       document-body
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  var observer = new MutationObserver(function(mutationList, observer) {
    mutationList.forEach(function(event) {

      if (event.addedNodes.length && event.target.className === 'blacklist'
          && event.target.tagName === 'DIV') {

        event.addedNodes.forEach(function(addedNode) {

          if (addedNode.classList
              && addedNode.classList.contains('user-info-blacklist-wrap')) {

            var links = addedNode.getElementsByClassName('user name');

            Array.from(links).forEach(
                function(link) {

                  var cell = link.parentNode.parentNode.parentNode;
                  var okStatus = !!cell
                      .getElementsByClassName('user-green-status ').length;

                  if (!okStatus) {
                    cell.style.display = 'none';
                    return;
                  }

                  var destination = link.href;
                  var id = destination.match(/\/profiles\.php\?XID=(\d*)/)[1];

                  var attackLink = document.createElement('a');
                  attackLink.innerHTML = 'Attack';
                  attackLink.target = '_blank';
                  attackLink.href = '/loader.php?sid=attack&user2ID=' + id;
                  link.after(attackLink);

                });
          }

        });

      }
    });

  });

  observer.observe(document.getElementsByTagName('body')[0], {
    childList : true,
    subtree : true
  });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址