Skip to content

Instantly share code, notes, and snippets.

@boxmein
Created March 22, 2015 21:02
Show Gist options
  • Select an option

  • Save boxmein/708b5259a2636c4d38ff to your computer and use it in GitHub Desktop.

Select an option

Save boxmein/708b5259a2636c4d38ff to your computer and use it in GitHub Desktop.
Turns Powder Toy Forum's "Conversations" page into a tiny Freenode webchat box. Sorry if it's quite crappy - the script is a hundred years old!
// ==UserScript==
// @name Powder Toy site Webchat
// @description Replaces Powder Toy site "Conversations" with webchat window. Turn off by turning off the script.
// @namespace boxmein.net
// @include http://powdertoy.co.uk/*
// @version 1.0
// ==/UserScript==
/* Webchat.js
* Turns powdertoy.co.uk's Conversations window into a qwebirc IRC box for #powder and #powder-social
* on Freenode.
* Turn off by turning off the script :(
* Public domain.
*/
var enabled = true; // Show / hide the webchat
var checkboxEnable = true; // Show / hide the small notification box
var frame = "<iframe src=\"http://webchat.freenode.net?channels=powder,powder-social&uio=d4\" width=\"568\" height=\"400\" style=\"border: none\"></iframe>";
var showCredit = true ? " by <a href=\"boxmein.web44.net\">boxmein</a>" : ""; // Do you want credits?
var element = document.createElement("div");
var init = function() {
if(checkboxEnable && document.getElementById("webChatBox") == null) {
createCheckBox();
}
if(enabled && window.location.href.match(/Conversations\.html/) != null) {
updateWindow(true);
}
};
var updateWindow = function(toWhat) {
if(toWhat) {
document.getElementById("isEnabled").innerHTML = "Changing to frame!";
document.getElementsByClassName("Subpage")[0].innerHTML = "Webchat frame" + showCredit + "<br />" + frame;
document.getElementById("isEnabled").innerHTML = "Ready.";
}
else if(!toWhat) {
location.reload(true); // If you don't want, then refresh.
}
}
var removeCheckBox = function() {
document.removeChild(element);
}
var createCheckBox = function() {
element.setAttribute("style", "float: right; position: fixed; background-color: rgba(0,0,0,0.5); font-family: \"Georgia\", serif; color: white; padding: 1px; border: 1px solid rgba(0,0,0,0.9)");
element.setAttribute("id", "webChatBox");
element.setAttribute("align", "center");
element.innerHTML = "<p>Conversations->Webchat is enabled.(<span id=\"isEnabled\">Enabled</span>)</p>";
document.body.appendChild(element);
};
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment