PDA

View Full Version : A userscript to re-enable WotC boards functionality from the web archive



martixy
2016-01-20, 03:53 PM
It may seem odd to place this here, but it is probably where it would reach the most audience that would make use of it.

So far it does only one thing - makes expanding and collapsing spoiler tags work again.
An example being this page: https://web.archive.org/web/20150219042020/http://community.wizards.com/forum/previous-editions-character-optimization/threads/1117261

If you have other ideas, feel free to share them.


Usage:
Just create a new userscript in greasemonkey or tampermonkey and put this code inside.

// ==UserScript==
// @name Web Archive WotC forums jQ inject
// @namespace https://web.archive.org
// @version 0.2
// @description Making broken boards usable since... whenever I decided to bother.
// @author martixy
// @match https://web.archive.org/web/*/http://community.wizards.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
// @grant none
// @copyright 2015+, martixy
// ==/UserScript==
/* jshint -W097 */
//'use strict';

/*
==========
Changelog:
==========
v0.1 (20/01/2016)
+Inject jQ and enable spoiler collapse/expand

v0.2 (21/01/2016)
+Fix www links to web enhancements to point at WotC archive. Now instead of using web archive, it redirects you to the still-up archives.
~Also proper inject(FWIW). This removes the jQuery is not defined error(if the script is set to run at document start). Pointless, but eh.
*/

$(function(){
//Spoiler expand fix
$(".xbbcode-spoiler-toggle").on("click", function(event) {
event.preventDefault();
var el = $(this).next().find(">:first-child");
if($(el).hasClass("xbbcode-spoiler-content"))
$(el).removeClass("xbbcode-spoiler-content");
else
$(el).addClass("xbbcode-spoiler-content");
});

//WotC archive redirect
$("a[href*='default.asp?x=dnd']").each(function() {
var newLocation = $(this).attr("href");
newLocation = "http://archive." + newLocation.substring(newLocation.indexOf("wizards.com/default.asp?x=dnd"));
$(this).attr("href", newLocation);
$(this).attr("title", newLocation);
});
});

Edit1: So I just added a small new bit:
Now all links to the WotC web enhancements go to the WotC archive, instead of the Web archive or the non-existent www address.

DarkSoul
2016-01-20, 04:11 PM
Works great. Tried before and after installing the script, and does exactly what it's supposed to.

GilesTheCleric
2016-01-20, 06:39 PM
Thank you, martixy. I'll add a link from the Index of 3.X WotC Threads (http://www.giantitp.com/forums/showthread.php?444041-Threads-from-the-Wizards-forums).