User:VeganCritter/DnD Beyond Tooltips

Planning Phase

 * Figure out to what extent this is possible.
 * Contact D&D Beyond for permission.
 * If successful, this could drive Critter traffic to D&D Beyond so that they'll purchase the content, which would enable access through our wiki tooltips.  This level of integration could be a way to drive revenue toward D&D Beyond from the Critical Role audience, so I imagine they'd be thrilled to get it working if possible.  It would also strengthen the relationship between D&D Beyond and Critical Role from the audience side.
 * Ideally, access to the tooltips would be determined by the user's access to D&D Beyond.  When content isn't yet purchased, that's the tooltip that would appear.  That's currently how it functions on D&D Beyond.
 * If additional integration or permissions are needed on our Wikia, then contact Wikia for assistance.

WoWWiki
From w:c:wowwiki:MediaWiki:common.js: /* Wowhead tooltips */ // As Wikia does not support attributes on links, we need to pass the attribute from a parent span to the child. // Simply wrap the link (Alt) in span tags with the "wikia-wowhead-tooltip class, and the "data-rel" attribute which holds the rel the anchor would normally hold. For instance, Alt var wowheadLinks = $('.wikia-wowhead-tooltip').length - 1; $('.wikia-wowhead-tooltip').each(function(index) { var rel = $(this).attr('data-rel');  $('a',this).attr('rel',rel);  // Once the links are converted, load the Wowhead script  if (index === wowheadLinks) {    $.getScript('http://static.wowhead.com/widgets/power.js', function {      wowhead_tooltips = { "colorlinks": true, "iconizelinks": true, "renamelinks": true };    });  } });

D&D Beyond Code
Here's the HTML code that calls the tooltip: Command

window.CurseTips['waterdeep-tooltip'].handleTooltipData({"Type":"spell","Id":2032,"Tooltip":"

Command Spell Level 1st Casting Time 1 Action Range/Area 60 ft                Components V                Duration 1 Round School Enchantment Attack/Save  WIS Save Damage/Effect  You speak a one-word command to a creature you can see within range. The target must succeed on a Wisdom saving throw or follow the command on its next turn. The spell has no effect if the target is undead, if it doesn't understand your language, or if your command is directly harmful to it. \r Some typical commands and their effects follow. You might issue a command other than one described here. If you do so, the GM determines how the target behaves. If the target can't follow your command, the spell ends. \r Approach. The target moves toward you by the shortest and most direct route, ending its turn if it moves within 5 feet of you. \r Drop. The target drops whatever it is holding and then ends its turn. \r Flee. The target spends its turn moving away from you by the fastest available means. \r Grovel. The target falls prone and then ends its turn. \r Halt. The target doesn't move and takes no actions. A flying creature stays aloft, provided that it is able to do so. If it must move to stay aloft, it flies the minimum distance needed to remain in the air. \r At Higher Levels. When you cast this spell using a spell slot of 2nd level or higher, you can affect one additional creature for each slot level above 1st. The creatures must be within 30 feet of each other when you target them. ","SimpleOrAdvanced":"simple", "Url": "https://www.dndbeyond.com/spells/2032/tooltip?callback=window.CurseTips['waterdeep-tooltip'].handleTooltipData"})