User Tools

Site Tools


greasemonkey:ii-nutritional-value

ii-nutritional-value

Version 2

Version 2.0 Discussion Link
Version 2.0 Source Code

I wanted to change fledermaus' meat script, so that it automatically loaded all of the known values of meat for each NPC.
ii-nutritional-value.user.js
// ==UserScript==
// @name           ii-nutritional-value
// @namespace      http://users.pepperfish.net/vivek/ii/
// @description    Improbable Island Butchery Guide (remembers nutritional values - Updated by Nader)
// @include        http://www.improbableisland.com/*
// @include        http://improbableisland.com/*
// ==/UserScript==
var done = false;
var sieve = '//div[@class=\'maincolumn\']/h2/parent::*' + '|' +
'//td[@class=\'content\']/h2/parent::*' + '|' +
'//fieldset/legend/parent::*/div[@class=\'block\']';
var filter = '//div[@class=\'navbox\']/a[@class=\'nav\']' + '|' +
'//td[@class=\'navigation\']/a[@class=\'nav\']' + '|' +
'//td[@class=\'nav\']/a[@class=\'nav\']';
var nodes = document.evaluate(filter, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var corpse = null;
if (corpse = sessionStorage.getItem('ii/food/last-carcass'))
{
  var a = 0;
  var b = 0;
  var c = 0;
  var label = '';
  var butchery = document.evaluate(sieve, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  sessionStorage.removeItem('ii/food/last-carcass');
  for (var i = 0; i < butchery.snapshotLength; i++)
  {
    var raw = butchery.snapshotItem(i).textContent;
    var got = null;
    // GM_log( "processing raw text: " + 
    //         butchery.snapshotItem(i) + " : " + raw );
    if (got = raw.match('You tear off enough to make ([0-9]+) rough bite'))
    {
      a += got[1] * 1;
    }
    if (got = raw.match('the fattier muscle, and before too long ' +
    'you have ([0-9]+) rough bite'))
    {
      b += got[1] * 1;
    }
    if (got = raw.match('slide easily from the bone, and you ' +
    'wind up with ([0-9]+) rough bite'))
    {
      c += got[1] * 1;
    }
  }
  // only log the value if we successfully parsed at least one category:
 
  if ((a > 0) || (b > 0) || (c > 0))
  {
    label = '(' + a + ', ' + b + ', ' + c + ')';
    localStorage.setItem(corpse, label);
    // GM_log( "storing " + corpse + " value : " + label );
    done = true;
  }
}
for (var x = 0; x < nodes.snapshotLength; x++)
{
  var node = nodes.snapshotItem(x);
  var text = node.textContent;
  var what = null;
  if (what = text.match('Clean\\s+the\\s+carcass\\s+of\\s+(.*?)\\s+\\('))
  {
    label = '(0, 0, 80)';
    corpse = 'ii/food/FakeFake';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/40\'s Glam Rocker';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/A G-nother G-nu';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 0)';
    corpse = 'ii/food/Admiral Flufferson';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 6)';
    corpse = 'ii/food/Adult Mouldywarp';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Albert';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Ambush Hamster';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 0)';
    corpse = 'ii/food/Angry squat';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Animated Aubergine';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Another Goddamn Monster';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Anthropomorphosized Circular Saw Philosopher';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Anti-Busker';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 5)';
    corpse = 'ii/food/Araneafelis Gigantea';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Archaeopteryx';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Armoured Housefly';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 4)';
    corpse = 'ii/food/Army of Hippopotami';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 3)';
    corpse = 'ii/food/Atinlay Igpay';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 0)';
    corpse = 'ii/food/Bar Fly';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 8)';
    corpse = 'ii/food/Bear Strapped to the Back of Another Bear';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Bees and Ants';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Beholder of the Behinder';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Berserk Gardener';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Bert & Ernie';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 5)';
    corpse = 'ii/food/Betentacled Horror';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Bettie the Amazing Kung-Fu Butterfly';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 1)';
    corpse = 'ii/food/Bicyclops';
    localStorage.setItem(corpse, label);
    label = '(7, 0, 0)';
    corpse = 'ii/food/Blair Hippo';
    localStorage.setItem(corpse, label);
    label = '(4, 2, 0)';
    corpse = 'ii/food/Blonde Heiress';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 0)';
    corpse = 'ii/food/Bluebird of Happiness';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Bookface';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Broadway Extra';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Bumbling Ally';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Cafeteria Lady';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Canadian Mosquito';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Canned Leeches';
    localStorage.setItem(corpse, label);
    label = '(7, 0, 0)';
    corpse = 'ii/food/Cattywampus';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Cereal Killer';
    localStorage.setItem(corpse, label);
    label = '(0, 3, 0)';
    corpse = 'ii/food/Cloned Diehard Harry Potter Fan';
    localStorage.setItem(corpse, label);
    label = '(0, 10, 0)';
    corpse = 'ii/food/Cloud of Reporters';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Completely Rational Monster';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Concerned Parent';
    localStorage.setItem(corpse, label);
    label = '(20, 0, 0)';
    corpse = 'ii/food/Conglomeration of Probable Creatures';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Conservative Party Advocate';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 2)';
    corpse = 'ii/food/Copy Cat';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Count of Monte Python';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 5)';
    corpse = 'ii/food/Crab Herdism';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Crafty Joker';
    localStorage.setItem(corpse, label);
    label = '(5, 1, 4)';
    corpse = 'ii/food/Crap Meat';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Crazed Tech Support Rep';
    localStorage.setItem(corpse, label);
    label = '(25, 0, 0)';
    corpse = 'ii/food/Creature from a Dodgy Anime';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Creepy Looking Guy in a Trenchcoat';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Cryptic Questions Joker';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Custodian of the Slushpile of Doom';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Cyrano DeBergerac';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 3)';
    corpse = 'ii/food/Dali the Four-Clawed Lobster';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Dan';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/David Attenborough';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Death or Cake Man';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Delicious Soup';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 0)';
    corpse = 'ii/food/Delusional Lunatic';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 1)';
    corpse = 'ii/food/Delusional, Blue-Spandex-Wearing Lunatic';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 1)';
    corpse = 'ii/food/Delusional, Green-Spandex-Wearing Lunatic';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Devil';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 2)';
    corpse = 'ii/food/Dick';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 2)';
    corpse = 'ii/food/Dingo-Eating Baby';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Diplomat';
    localStorage.setItem(corpse, label);
    label = '(5, 0, 0)';
    corpse = 'ii/food/Dirty Chippy';
    localStorage.setItem(corpse, label);
    label = '(6, 0, 0)';
    corpse = 'ii/food/Diseased Lung';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Disney Historical Accuracy Department';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Disney Historical Fallacy Department';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Doggymorph';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Don of the Dead';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 4)';
    corpse = 'ii/food/Draughtsbeast';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Drunken Nudist';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Duck & Penguin in Spats';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Dump Truck Operator';
    localStorage.setItem(corpse, label);
    label = '(3, 0, 0)';
    corpse = 'ii/food/Earwigs';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 0)';
    corpse = 'ii/food/Elrod Gulch';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Emily the Buxom Barmaid';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Emo Boy';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Emu';
    localStorage.setItem(corpse, label);
    label = '(5, 2, 0)';
    corpse = 'ii/food/Enchanted Stewpot';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 3)';
    corpse = 'ii/food/Evolution\'s Greatest Failure';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 2)';
    corpse = 'ii/food/Fat Butcher';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Father Time';
    localStorage.setItem(corpse, label);
    label = '(3, 0, 0)';
    corpse = 'ii/food/Felonious Skunk';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Feral Budget Horse';
    localStorage.setItem(corpse, label);
    label = '(3, 3, 3)';
    corpse = 'ii/food/Feral Kittybikes';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Filthy Thieving Squats';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Fire Alarm';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Fire-Breathing Kangaroo';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Flesh-Eating Virus';
    localStorage.setItem(corpse, label);
    label = '(4, 2, 2)';
    corpse = 'ii/food/Flock of Fanboys';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Flock of Migratory Teakettles';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Flock of Swallows';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Flying Helper Monkey';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 4)';
    corpse = 'ii/food/Flying Hipster Pig';
    localStorage.setItem(corpse, label);
    label = '(4, 1, 0)';
    corpse = 'ii/food/Flying Sea Serpent';
    localStorage.setItem(corpse, label);
    label = '(5, 2, 0)';
    corpse = 'ii/food/Flying Spaghetti Monster';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Foilwench';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 2)';
    corpse = 'ii/food/Foreign Meatloaf Dinner';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 2)';
    corpse = 'ii/food/Foreign Traveler';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Gary Gygax';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 1)';
    corpse = 'ii/food/Gary Larson';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Generic Monster';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Giant Squat';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Giant Teddy Bear';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Goddamn Aye-aye';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Gordon the Cheese Eater';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Gothic Romantic Heroine';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 1)';
    corpse = 'ii/food/Grammar Police';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 1)';
    corpse = 'ii/food/Great-Aunt Alice';
    localStorage.setItem(corpse, label);
    label = '(0, 5, 1)';
    corpse = 'ii/food/Grue';
    localStorage.setItem(corpse, label);
    label = '(3, 3, 0)';
    corpse = 'ii/food/Guerilla Gorilla';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Guy Who Keeps Running Behind You';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 3)';
    corpse = 'ii/food/Ham Bush';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 4)';
    corpse = 'ii/food/Hannibal Lecture';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Harry Potter Reenactor';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Health and Safety Inspector';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 2)';
    corpse = 'ii/food/Hiker';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 4)';
    corpse = 'ii/food/Hippopotamus';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Hover Leech (Canned Leeches)';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Humanmorph';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 6)';
    corpse = 'ii/food/Humongous Giant Clam';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 2)';
    corpse = 'ii/food/Immortal Slasher Villain';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 3)';
    corpse = 'ii/food/Insurance Salesman';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 5)';
    corpse = 'ii/food/Interrupting Cow';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Jokosquabotantmorph';
    localStorage.setItem(corpse, label);
    label = '(6, 0, 0)';
    corpse = 'ii/food/Kentucky Fried Zombie';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Kierkegaard';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 1)';
    corpse = 'ii/food/Lame Ass';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 4)';
    corpse = 'ii/food/Land Shark';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 0)';
    corpse = 'ii/food/Lemming';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Little Old Lady';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Lolrus';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 1)';
    corpse = 'ii/food/Loud Hecklers';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Mad Scrabble Player';
    localStorage.setItem(corpse, label);
    label = '(2, 3, 0)';
    corpse = 'ii/food/Madness Duck';
    localStorage.setItem(corpse, label);
    label = '(2, 3, 0)';
    corpse = 'ii/food/Madness Duck';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Man from the Ministry';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 0)';
    corpse = 'ii/food/Master of Disguise';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Mathematician';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Member of Doktor Improbable Lovers Anonymous';
    localStorage.setItem(corpse, label);
    label = '(0, 3, 0)';
    corpse = 'ii/food/Mephistopheles, Duck of Hell';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Metamorphic Mess';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Meter Maid';
    localStorage.setItem(corpse, label);
    label = '(3, 3, 0)';
    corpse = 'ii/food/Militant Pacifist';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Milk Beast';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 2)';
    corpse = 'ii/food/Mini-Minotaur';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 2)';
    corpse = 'ii/food/Mongol Hordette';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 4)';
    corpse = 'ii/food/Monkey Ghostwriter Franchise';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Monster At The End of This Path';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 4)';
    corpse = 'ii/food/Moose';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 0)';
    corpse = 'ii/food/Motorcycle Daredevil';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Mouldywarp';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 0)';
    corpse = 'ii/food/NASCAR Fan';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 0)';
    corpse = 'ii/food/Network Sponsor';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 4)';
    corpse = 'ii/food/Ninjas';
    localStorage.setItem(corpse, label);
    label = '(0, 3, 0)';
    corpse = 'ii/food/Nitro Bunny';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 1)';
    corpse = 'ii/food/Occam\'s Razorback';
    localStorage.setItem(corpse, label);
    label = '(1, 6, 1)';
    corpse = 'ii/food/Octophant';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 0)';
    corpse = 'ii/food/Old Crippled Beggar';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Ooze';
    localStorage.setItem(corpse, label);
    label = '(7, 2, 0)';
    corpse = 'ii/food/Orc';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Oronte';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Pacifist';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Pack of Chewing Gum';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 10)';
    corpse = 'ii/food/Panthzer';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Passive-Aggressive Co-worker';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/People on Streets';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Phony Psychic';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 5)';
    corpse = 'ii/food/Pile of Uncooked Meat';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Pinball Wizard';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Pizza That Time Forgot';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Play on Words';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Poisonous Strangler Vines of Doom';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Pope';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Potato News Caster';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Poultrygeist';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Predatory Petitioner';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Pretentious Jerks';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Professional Romance Writer';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 4)';
    corpse = 'ii/food/Puppies of a Minor Diplomatic Incident';
    localStorage.setItem(corpse, label);
    label = '(4, 2, 0)';
    corpse = 'ii/food/Purple People Eater';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Quivering Flesh Heap';
    localStorage.setItem(corpse, label);
    label = '(12, 0, 0)';
    corpse = 'ii/food/Rabid Suburban Squirrel Hive';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Rat Pack';
    localStorage.setItem(corpse, label);
    label = '(3, 4, 5)';
    corpse = 'ii/food/Ravening Bugblatter Beast of Aaaaaaaaarrrgh';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Red Herring';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Reginald, Your Paper Boy';
    localStorage.setItem(corpse, label);
    label = '(20, 0, 0)';
    corpse = 'ii/food/Rejected Monsters';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Religious Zombie';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Reluctant Cannibal';
    localStorage.setItem(corpse, label);
    label = '(2, 4, 2)';
    corpse = 'ii/food/Reluctant Rabbits';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Rind Flayer';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Robert Catesby';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Rodent Of Unusual Size';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Rogue Orrery';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Rude Duplicate Creature';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Rush Hour Driver';
    localStorage.setItem(corpse, label);
    label = '(5, 1, 0)';
    corpse = 'ii/food/Santa';
    localStorage.setItem(corpse, label);
    label = '(3, 0, 0)';
    corpse = 'ii/food/Schrodinger\'s Other Cat';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Scotsman Clad in Kilt';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Scrabble Players Anonymous';
    localStorage.setItem(corpse, label);
    label = '(20, 0, 0)';
    corpse = 'ii/food/Season Three Test Monster';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Self-Conscious Dwarf';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Seth the Handsome Bard';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Seven Filthy Thieving Squats';
    localStorage.setItem(corpse, label);
    label = '(50, 0, 0)';
    corpse = 'ii/food/Seventy-Headed Hellhound';
    localStorage.setItem(corpse, label);
    label = '(0, 4, 0)';
    corpse = 'ii/food/Shaggy Dog';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Sigmund Freud';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Sinister Dexter';
    localStorage.setItem(corpse, label);
    label = '(4, 2, 4)';
    corpse = 'ii/food/Smog';
    localStorage.setItem(corpse, label);
    label = '(4, 4, 0)';
    corpse = 'ii/food/Snake Oil Salesman';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Society of British Bedstead Men';
    localStorage.setItem(corpse, label);
    label = '(8, 0, 0)';
    corpse = 'ii/food/Socktopus';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 1)';
    corpse = 'ii/food/Someone Else\'s Quest Monster';
    localStorage.setItem(corpse, label);
    label = '(1, 3, 1)';
    corpse = 'ii/food/Someone With Caterpillars in Their Vagina';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 2)';
    corpse = 'ii/food/Son of Budget Cow';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 2)';
    corpse = 'ii/food/Son of Budget Horse';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 2)';
    corpse = 'ii/food/Sorority Girl in Nightie';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 1)';
    corpse = 'ii/food/SpiderKitty';
    localStorage.setItem(corpse, label);
    label = '(7, 3, 0)';
    corpse = 'ii/food/SpiderMorph';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Squat Paladin';
    localStorage.setItem(corpse, label);
    label = '(3, 1, 0)';
    corpse = 'ii/food/Squat Plumber';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Squat with Fungal Infection';
    localStorage.setItem(corpse, label);
    label = '(7, 1, 0)';
    corpse = 'ii/food/Squat Zombie Mutant';
    localStorage.setItem(corpse, label);
    label = '(12, 0, 0)';
    corpse = 'ii/food/Squats from the Train Station';
    localStorage.setItem(corpse, label);
    label = '(12, 0, 0)';
    corpse = 'ii/food/Squats from the Travel Agency';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 1)';
    corpse = 'ii/food/Squats with Matching Factory Uniforms';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Squicky the Bunny';
    localStorage.setItem(corpse, label);
    label = '(2, 2, 0)';
    corpse = 'ii/food/Star Wars Nerd';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 2)';
    corpse = 'ii/food/Stereotypical Severe Nun';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Storm Snail';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Strict Non-Smoker';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/S-Trumpet';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Tall Squat';
    localStorage.setItem(corpse, label);
    label = '(5, 0, 0)';
    corpse = 'ii/food/Team Awesome';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/That Cutie from Work';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/The Angler';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/The Eggman';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/The Guy Who Couldn\'t Beat Tom Carney';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/The Tooth Fairy';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/The Unreality of Time';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 3)';
    corpse = 'ii/food/The Walrus';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Thesaurus Rex';
    localStorage.setItem(corpse, label);
    label = '(2, 0, 0)';
    corpse = 'ii/food/Thing from the Back Of The Fridge';
    localStorage.setItem(corpse, label);
    label = '(0, 1, 0)';
    corpse = 'ii/food/Thing in the Attic';
    localStorage.setItem(corpse, label);
    label = '(2, 3, 1)';
    corpse = 'ii/food/This Guy';
    localStorage.setItem(corpse, label);
    label = '(3, 3, 0)';
    corpse = 'ii/food/Three Droogs';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 5)';
    corpse = 'ii/food/Three French Hens';
    localStorage.setItem(corpse, label);
    label = '(3, 0, 0)';
    corpse = 'ii/food/Three-Toed Sloth';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Tom Cruise';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Totally Baffling Reference';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Tour Guide';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Towel-less Hitchhiker';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 3)';
    corpse = 'ii/food/Turkey';
    localStorage.setItem(corpse, label);
    label = '(0, 5, 0)';
    corpse = 'ii/food/Typical Squaresoft Hero';
    localStorage.setItem(corpse, label);
    label = '(7, 0, 0)';
    corpse = 'ii/food/Typo Gremlin';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 4)';
    corpse = 'ii/food/Unbeatable Monster';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 4)';
    corpse = 'ii/food/Undead Dreaming Catfish God';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Unicycle Entertainer';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Union Member With Seniority';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Unlicensed Plastic Surgeon';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 1)';
    corpse = 'ii/food/Unlucky Bastard';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 0)';
    corpse = 'ii/food/Uranium Man';
    localStorage.setItem(corpse, label);
    label = '(4, 2, 1)';
    corpse = 'ii/food/Urbane Antagonist';
    localStorage.setItem(corpse, label);
    label = '(4, 3, 0)';
    corpse = 'ii/food/Vampire-Bat Prince';
    localStorage.setItem(corpse, label);
    label = '(6, 0, 0)';
    corpse = 'ii/food/Vegan Zombie';
    localStorage.setItem(corpse, label);
    label = '(1, 3, 0)';
    corpse = 'ii/food/Velociraptor';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 2)';
    corpse = 'ii/food/Veteran Player';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Vigilante';
    localStorage.setItem(corpse, label);
    label = '(0, 2, 4)';
    corpse = 'ii/food/Violin Suspense';
    localStorage.setItem(corpse, label);
    label = '(3, 2, 3)';
    corpse = 'ii/food/Walrus';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Washed-Up Celebrity';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 0)';
    corpse = 'ii/food/Weatherman';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Well-Meaning Moron';
    localStorage.setItem(corpse, label);
    label = '(10, 0, 5)';
    corpse = 'ii/food/Whale';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 1)';
    corpse = 'ii/food/Whining Old-School Gamer';
    localStorage.setItem(corpse, label);
    label = '(3, 0, 0)';
    corpse = 'ii/food/Whopper with Cheese';
    localStorage.setItem(corpse, label);
    label = '(0, 4, 4)';
    corpse = 'ii/food/Wild Horses';
    localStorage.setItem(corpse, label);
    label = '(0, 6, 0)';
    corpse = 'ii/food/Wild Monkeys';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 2)';
    corpse = 'ii/food/Wizard of Yendor';
    localStorage.setItem(corpse, label);
    label = '(4, 4, 0)';
    corpse = 'ii/food/Wolpertinger';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 0)';
    corpse = 'ii/food/Work Experience Lads';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Yesterday\'s Salad';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Your Future Self';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Your In-Laws';
    localStorage.setItem(corpse, label);
    label = '(0, 0, 1)';
    corpse = 'ii/food/Your Own Tongue';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Your Past Self';
    localStorage.setItem(corpse, label);
    label = '(2, 1, 0)';
    corpse = 'ii/food/Your Pasta Self';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Your Present Self';
    localStorage.setItem(corpse, label);
    label = '(1, 1, 2)';
    corpse = 'ii/food/Zen Master';
    localStorage.setItem(corpse, label);
    label = '(5, 0, 0)';
    corpse = 'ii/food/Zombie Kitten';
    localStorage.setItem(corpse, label);
    label = '(4, 0, 0)';
    corpse = 'ii/food/Zombie Puppy';
    localStorage.setItem(corpse, label);
    label = '(1, 0, 0)';
    corpse = 'ii/food/Zombie Worm';
    localStorage.setItem(corpse, label);
    label = '(1, 2, 1)';
    corpse = 'ii/food/Zombified Luciano Pavarotti';
    localStorage.setItem(corpse, label);
    var target = what[1];
    var key = 'ii/food/' + target;
    var value = localStorage.getItem(key);
    // GM_log( "cached value(s) for '" + target + "'" );
    // duff stored value 
    if (value == '(0, 0, 0)')
    {
      done = false;
      value = null;
      localStorage.removeItem(key);
    }
    if (!done) {
      sessionStorage.setItem('ii/food/last-carcass', key);
    }
    // GM_log( "looking up '" + key + "'");
 
    if (value)
    {
      // GM_log( target + " == " + value );
      node.setAttribute('title', value);
    } 
    else
    {
      // GM_log( key + " == null" );
      node.setAttribute('title', '(?, ?, ?)');
    }
  }
}

Version 1

Version 1.2

ii-nutritional-value.user.js
// ==UserScript==
// @name           ii-nutritional-value
// @namespace      http://users.pepperfish.net/vivek/ii/
// @description    Improbable Island Butchery Guide (remembers nutritional values)
// @include        http://www.improbableisland.com/*
// @include        http://improbableisland.com/*
// ==/UserScript==
 
var done   = false;
var sieve  = "//div[@class='maincolumn']/h2/parent::*" + "|" +
             "//td[@class='content']/h2/parent::*"     + "|" +
             "//fieldset/legend/parent::*/div[@class='block']";
var filter = "//div[@class='navbox']/a[@class='nav']"    + "|" +
             "//td[@class='navigation']/a[@class='nav']" + "|" +
             "//td[@class='nav']/a[@class='nav']";
var nodes  = document.evaluate( filter, document, null,
                                XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
                                null );
var corpse = null; 
 
if( corpse = sessionStorage.getItem('ii/food/last-carcass') )
{
    var a = 0;
    var b = 0;
    var c = 0;
    var label = "";
    var butchery = document.evaluate( sieve, document, null,
                                      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
                                      null );
 
    sessionStorage.removeItem('ii/food/last-carcass');
 
    for( var i = 0; i < butchery.snapshotLength; i++ )
    {
        var raw = butchery.snapshotItem(i).textContent;
        var got = null;
 
        // GM_log( "processing raw text: " + 
        //         butchery.snapshotItem(i) + " : " + raw );
 
        if( got = raw.match("You tear off enough to make ([0-9]+) rough bite") )
        {
            a += got[1] * 1;
        }
 
        if( got = raw.match("the fattier muscle, and before too long "+ 
                            "you have ([0-9]+) rough bite") )
        {
            b += got[1] * 1;
        }
 
        if( got = raw.match("slide easily from the bone, and you " + 
                            "wind up with ([0-9]+) rough bite") )
        {
            c += got[1] * 1;
        }
    }
 
    // only log the value if we successfully parsed at least one category:
    if( (a > 0) || (b > 0) || (c > 0) )
    {
        label = "(" + a + ", " + b + ", " + c + ")";
        localStorage.setItem( corpse, label );
        // GM_log( "storing " + corpse + " value : " + label );
        done = true;
    }
}
 
for( var x = 0; x < nodes.snapshotLength; x++ )
{
    var node = nodes.snapshotItem(x);
    var text = node.textContent;
    var what = null;
 
    if( what = text.match("Clean\\s+the\\s+carcass\\s+of\\s+(.*?)\\s+\\(") )
    {
        var target = what[1];
        var key    = 'ii/food/' + target;
        var value  = localStorage.getItem(key);
 
        // GM_log( "cached value(s) for '" + target + "'" );
 
        // duff stored value 
        if( value == "(0, 0, 0)" ) 
        { 
            done = false; 
            value = null;
            localStorage.removeItem( key );
        }
 
        if( !done ) { sessionStorage.setItem('ii/food/last-carcass', key); }
 
        // GM_log( "looking up '" + key + "'");
        if( value )
        {
            // GM_log( target + " == " + value );
            node.setAttribute( "title", value );
        }
        else
        {
            // GM_log( key + " == null" );
            node.setAttribute( "title", "(?, ?, ?)" );
        }
    }
}
greasemonkey/ii-nutritional-value.txt · Last modified: 2023/11/21 18:04 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki