diff --git a/tfdclerk.js b/tfdclerk.js
index 61d83bc..933aacf 100644
--- a/tfdclerk.js
+++ b/tfdclerk.js
@@ -28,4 +28,52 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-// TODO
+mw.loader.using(["mediawiki.api"], function() {
+ if (mw.config.get("wgNamespaceNumber") != 4 || (
+ mw.config.get("wgTitle") != "Templates for discussion" &&
+ mw.config.get("wgTitle").indexOf("Templates for discussion/Log/2") != 0))
+ return;
+
+ TFDClerk = {
+ // TODO
+ };
+
+ TFDClerk.close = function(head) {
+ // TODO
+ console.log("closing");
+ console.log(head);
+ };
+
+ TFDClerk.relist = function(head) {
+ // TODO
+ console.log("relisting");
+ console.log(head);
+ };
+
+ TFDClerk._build_hook = function(head, name, callback) {
+ return $("", {style: "margin-left: 1em;"})
+ .append($("", {addClass: "mw-editsection-bracket", text: "["}))
+ .append($("", {
+ href: "#",
+ text: name,
+ click: function(h) {
+ return function() { callback(h); return false; }
+ }(head)
+ }))
+ .append($("", {addClass: "mw-editsection-bracket", text: "]"}));
+ };
+
+ TFDClerk.install = function() {
+ $("h4").each(function(i, head) {
+ if ($(head).next().hasClass("tfd-closed"))
+ return;
+
+ $("", {addClass: "tfdclerk-hooks"})
+ .append(TFDClerk._build_hook(head, "close", TFDClerk.close))
+ .append(TFDClerk._build_hook(head, "relist", TFDClerk.relist))
+ .appendTo($(head).find(".mw-editsection"));
+ });
+ };
+
+ $(TFDClerk.install);
+});