Namize Background Ponies!

Namize Background Ponies on Derpibooru!

  1. // ==UserScript==
  2. // @name Namize Background Ponies!
  3. // @namespace http://derpiboo.ru/images/namize_bp
  4. // @description Namize Background Ponies on Derpibooru!
  5. // @icon https://dl.dropboxusercontent.com/u/7410519/ScreenS/Derpy_by_TheShadowArtist100.png
  6. // @include http://derpiboo.ru/*
  7. // @include http://www.derpiboo.ru/*
  8. // @include http://trixiebooru.org/*
  9. // @include http://www.trixiebooru.org/*
  10. // @include http://derpibooru.org/*
  11. // @include http://www.derpibooru.org/*
  12. // @include https://derpiboo.ru/*
  13. // @include https://www.derpiboo.ru/*
  14. // @include https://trixiebooru.org/*
  15. // @include https://www.trixiebooru.org/*
  16. // @include https://derpibooru.org/*
  17. // @include https://www.derpibooru.org/*
  18. // @include https://ronxgr5zb4dkwdpt.onion/*
  19. // @include https://www.ronxgr5zb4dkwdpt.onion/*
  20. // @version 1.026
  21. // @grant none
  22. // @require https://greasyfork.org/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=2765
  23. // ==/UserScript==
  24.  
  25. //Change this
  26. //vvv
  27.  
  28. var colored = true; //change this to false if you don't like colors
  29. var fullNameColor = false; //true - full name will be coloured
  30. //false - only marker will be coloured
  31. var addBackgroundPony = true;//change this to false if you don't wish add " (Background Pony)" to the end of anon's "names"
  32.  
  33. //------------------------------------------------------------------------------------------------
  34. //Do not change this (if you user. Programmers/scripters can change this)
  35. //vvv
  36.  
  37. var names1 = ["","8-bit","Aero","Air","Almond","Alpha","Amaranthine","Amber","American","Annoying","Apple","Apricot","Aqua","Asian","Astral","Awesome","Bad","Beauty","Beige","Bell","Belle","Berry","Big","Bitter","Black","Blaze","Blazing","Blue","Bold","Bon","Bright","Brisk","Broken","Bronze","Brown","Candy","Caramel","Careless","Carrot","Charming","Cherry","Chilly","Chimmy","Choco","Chocolate","Chromatic","Chubby","Citric","Classic","Clean","Clear","Clever","Cloudy","Cocky","Coco","Cold","Cool","Copper","Corky","Correct","Cosmic","Cranky","Crazy","Curly","Cute","Cutie","Da’","Daring","Dark","Deadly","Delta","Derpy","Desert","Desired","Diamond","Dim","Dirty","Ditzy","Dizzy","DJ","Doctor","Double","Drama","Dusk","Eastern","Easy","Emerald","Empress","Epic","European","Fancy","Fantastic","Fast","Fat","Fifth","Filthy","First","Flash","Flirtatious","Fluffy","Flutter","Foggy","Fourth","Full","Funny","Fuzzy","Gamma","General","Gentle","Ginger","Glass","Glitter","Golden","Good","Gotta","Gray","Green","Half","Half Baked","Handsome","Happy","Hard","Hasty","Heavy","Hematite","High","Holly","Honey","Horny","Hot","Hyper","Ice","Igneous","Innocent","Iron","Ivory","Jasper","Large","Last","Lavender","Legendary","Lemon","Lemony","Liberty","Light","Lightning","Lilac","Little","Lone","Long","Lovely","Low","Lucky","Main","Malachite","Melo","Metal","Meteor","Mini","Misty","Mixed","Mud","Multicolored","My Little","Mysterious","Mythical","Navy","Neat","Neon","Night","Noisy","Northern","Nurse","Nyan","Old","Olive","Omega","Onyx","Orange","Over","Paper","Party","Peachy","Pear","Pearl","Perfect","Pink","Pinkie","Platinum","Plumy","Princess","Professor","Proud","Pure","Purple","Quartz","Queen","Quick","Rainbow","Rainy","Red","Rosy","Ruby","Ruff","Sad","Sapphire","Saucy","Sea","Second","Shadow","Sharp","Shining","Short","Shy","Silken","Silver","Simply","Slow","Smart","Smooth","Snappy","Sneaky","Soft","Sonic","Southern","Speedy","Spicy","Starry","Stella","Stellar","Stellate","Stinkin'","Stolid","Strict","Strong","Sugar","Sunny","Super","Sweet","Tasty","The Great and Powerful","Third","Thunder","Timid","True","Turquoise","Twilight","Under","Vanilla","Violet","Warning","Western","White","Windy","Winy","Yellow"];
  38. var names2 = ["Angel","Apple","Apples","Armor","Armour","Assassin","Autumn","Barry","Beauty","Bee","Beetle","Bell","Belle","Berries","Blade","Blink","Blossom","Bomb","Bon","Bone","Bones","Book","Boom","Boomer","Bread","Brooch","Brook","Bubble","Bubbles","Bug","Bun","Bunny","Butterfly","Button","Cake","Candle","Candy","Cargo","Cat","Changa","Charge","Cherry","Cider","Class","Clearing","Cloud","Cola","Comet","Computer","Cook","Crasher","Crate","Cream","Creeper","Crown","Crush","Crusher","Cupcake","Cupcakes","Curse","Daiquiri","Dance","Dancer","Dash","Dasher","Dashy","Day","Days","Deal","Derp","Dessert","Devil","Dew","Diamond","Dog","Dovahkiin","Dream","Dress","Drop","Dubstep","Dust","Dusty","Earring","Eclair","Egg","Emerald","Envy","Eye","Eyes","Factory","Faith","Fall","Fear","Feather","Feathers","Fire","Flag","Flame","Flames","Flare","Floor","Flower","Flowers","Flyer","Folder","Forest","Fork","Frost","Glass","Ground","Halo","Harvest","Hawk","Hay","Haze","Head","Heart","Hills","Hoof","Hooves","Hope","Horn","Horns","Horseshoe","Horseshoes","Hunt","Hunter","Image","In Socks","Jam","Jazz","Journal","Kettle","Key","Kill","Kills","Knife","Knight","Ladle","Lady","Lake","Lamp","Leaf","Lemon","Lemonade","Light","List","Loaf","Love","Luna","Mane","Mess","Miner","Mint","Mints","Mist","Moon","Mouse","Muffin","Music","Necklace","Needle","News","Night","Nights","Noon","Note","Notes","Nova","Patty","Pepper","Picnic","Picture","Pie","Pirate","Pixel","Pony","Pop","Popper","Pride","Prism","Prod","Punk","Rainbow","Rat","Reaper","Rice","Ring","Rock","Roll","Romance","Rosette","Ruby","Runner","Saddle","Sapphire","Scapula","Shield","Shimmer","Shine","Shovel","Shower","Shy","Signal","Skies","Sky","Slapjack","Snap","Snow","Song","Soul","Sparkle","Sparky","Spawn","Sphere","Spider","Spin","Spirit","Spoon","Spring","Stairs","Star","Stars","Stool","Strike","String","Strings","Stripe","Stripes","Stuff","Summer","Sun","Swirl","Sword","Swords","Table","Tart","Tiara","Time","Times","Top","Tree","Trees","Trixie","Tron","Twist","Vise","Water","Waterfall","Wheat","Wind","Window","Wing","Wings","Winter","Wolf"];
  39.  
  40. textNodes = document.evaluate(
  41. ".//a | .//strong | .//div[@class='metasection'] | .//div[contains(concat(' ', normalize-space(@class), ' '), ' post-author ')] | .//div[@class='small'] | .//td[@class='topic-lastpost']", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  42. //var searchREF = new RegExp('Background Pony #([0-9A-F]{4})','g');
  43. var searchRER = new RegExp('Background Pony #([0-9A-F]{2})([0-9A-F]{2})','');
  44. /*var searchRER = new RegExp('Background Pony','gi');*/
  45. var replace = 'pling';
  46.  
  47.  
  48. function getBPName(re, match, overrideNoColors)
  49. {
  50. if(typeof(overrideNoColors)==='undefined') overrideNoColors=colored;
  51.  
  52. var index1 = parseInt(match[1],16);
  53. var index2 = parseInt(match[2],16);
  54. var replace=names1[index1];
  55. if (replace!='') replace+=' ';
  56. replace+=names2[index2];
  57. var span_open='<span title="'+match[1]+match[2]+'" style="color: '+getRGBstr(match[1]+match[2])+';">';
  58. if (overrideNoColors)
  59. {
  60. if (fullNameColor) replace=span_open+replace+'</span>';
  61. else replace+=span_open+' •</span>';
  62. }
  63. else replace='<span title="'+match[1]+match[2]+'">'+replace+'</span>';
  64. if (addBackgroundPony) replace+=" (Background Pony)";
  65. re=re.replace(searchRER, replace);
  66. return re;
  67. }
  68.  
  69.  
  70. for (var i=0;i<textNodes.snapshotLength;i++)
  71. {
  72. var node = textNodes.snapshotItem(i);
  73. var re = node.innerHTML;
  74. var match = re.match(searchRER);
  75. //alert(node.nodeName);
  76. if (match!=null)
  77. {
  78. re=getBPName(re, match);
  79. //re='123';
  80. node.innerHTML=re;
  81. }
  82. }
  83.  
  84. waitForKeyElements("div.comment_info > strong, div.comment_body a, div.post-prevue a, span.post-author, div.post-author, div.post-text a", get_span_content);
  85.  
  86. function getRGBstr(color16bit)
  87. {
  88. var pixel = parseInt(color16bit,16);
  89. var red_mask = 0xF800;
  90. var green_mask = 0x7E0;
  91. var blue_mask = 0x1F;
  92. var red_value = (pixel & red_mask) >> 11;
  93. var green_value = (pixel & green_mask) >> 5;
  94. var blue_value = (pixel & blue_mask);
  95. // Expand to 8-bit values.
  96. var red = red_value << 3;
  97. var green = green_value << 2;
  98. var blue = blue_value << 3;
  99. return 'rgb('+red+','+green+','+blue+')';
  100. }
  101.  
  102. function get_span_content (jNode)
  103. {
  104. var spanText = $.trim (jNode.text () );
  105. var lastText = jNode.data ("lastText") || "";
  106.  
  107. if (spanText != lastText) {
  108. // DO WHATEVER WITH spanText HERE.
  109.  
  110. //var re = jNode.html().replace(searchRER, replace);
  111. var re = jNode.html();
  112. match=searchRER.exec(re);
  113. if (match!=null)
  114. {
  115. re=getBPName(re, match);
  116. //re='123';
  117. jNode.html(re);
  118. }
  119. //alert(jNode.text());
  120.  
  121. jNode.data ("lastText", spanText);
  122. }
  123.  
  124. return true;
  125. }
  126.  
  127.  
  128. /**/
  129.