Greasy Fork

FARMASSI

DS-FARMASSSI Extension

目前为 2014-07-10 提交的版本。查看 最新版本

// ==UserScript==
// @name           FARMASSI 
// @namespace      DSFarmAssistentExtension
// @include        *die-staemme.de/game.php*screen=am_farm*
// @author         Dummbroesel
// @description    DS-FARMASSSI Extension
// @version		   1.3.1
// ==/UserScript==

//table row remove after inner button got clicked, activate with anykey
document.onkeypress = function(event) {
  console.dir(event);
  console.log(event.keyCode);
  switch (event.keyCode) {
    case 102: //f
      FARemove();
      break;
    case 81: //Q
      FAFirst();
      break;
    case 113: //q
      FAPrev();
      break;
    case 101: //e
      FANext();
      break;
    case 115: //s
     FASelect();
      break;
    default:
    break;
  }
}

function FARemove() {
  if ($('a.farm_icon_a') != null){
    $('a.farm_icon_a').click(function() {
      $(this).closest("tr").remove();
    });
  }
  if($('a.farm_icon_b') != null){
    $('a.farm_icon_b').click(function() {
      $(this).closest("tr").remove();
    });
  }
  if ($('a.farm_icon_c') != null) {
    $('a.farm_icon_c').click(function() {
      $(this).closest("tr").remove();
    });
  }
  console.log('FARMASSI ACTIVE');
}

function FAFirst() {
  var divCon = $('#am_widget_Farm');
  var allTd = divCon.find('td');
  var lastTd = allTd[allTd.length -1];
  var lastTd = $(lastTd);
  var lTdChilds = lastTd.children();
  lTdChilds.each(function (index) {
    if (this.tagName.toLowerCase() == 'strong' && index > 0) {
      window.location = lTdChilds[0].href;
    }
  });
}

function FAPrev() {
  var divCon = $('#am_widget_Farm');
  var allTd = divCon.find('td');
  var lastTd = allTd[allTd.length -1];
  var lastTd = $(lastTd);
  var lTdChilds = lastTd.children();
  lTdChilds.each(function (index) {
    if (this.tagName.toLowerCase() == 'strong' && index > 0) {
      window.location = lTdChilds[index - 1].href;
    }
  });
}

function FANext() {
  var divCon = $('#am_widget_Farm');
  var allTd = divCon.find('td');
  var lastTd = allTd[allTd.length -1];
  var lastTd = $(lastTd);
  var lTdChilds = lastTd.children();
  lTdChilds.each(function (index) {
    if (this.tagName.toLowerCase() == 'strong' && index < lTdChilds.length -2) {
      window.location = lTdChilds[index+1].href;
    }
  });
}

function FASelect() {
  var divCon = $('#am_widget_Farm');
  var allTd = divCon.find('td');
  var lastTd = allTd[allTd.length -1];
  var lastTd = $(lastTd);
  lastTd.find('select').focus();
}