Mugenmonkey: put DS1 build name in <title>
authorDariusz Murakowski <murakdar@gmail.com>
Wed, 23 May 2018 20:17:43 +0000 (16:17 -0400)
committerDariusz Murakowski <murakdar@gmail.com>
Wed, 23 May 2018 20:17:43 +0000 (16:17 -0400)
(Mugenmonkey) Dark Souls build title.user.js [new file with mode: 0644]

diff --git a/(Mugenmonkey) Dark Souls build title.user.js b/(Mugenmonkey) Dark Souls build title.user.js
new file mode 100644 (file)
index 0000000..f0e434d
--- /dev/null
@@ -0,0 +1,29 @@
+// ==UserScript==
+// @name         (Mugenmonkey) Dark Souls build title
+// @namespace    http://tampermonkey.net/
+// @version      0.2
+// @description  append build name to page title
+// @author       Dariusz Murakowski
+// @match        https://mugenmonkey.com/darksouls/*
+// @match        https://www.mugenmonkey.com/darksouls/*
+// @grant        none
+// @run-at       document-idle
+// ==/UserScript==
+
+(function() {
+    'use strict';
+
+    // from https://stackoverflow.com/questions/12685963/get-element-by-tag-and-class
+    // and https://stackoverflow.com/questions/18242171/get-element-by-tag-name-and-class-name
+    // see https://stackoverflow.com/questions/12011867/getelementbyid-and-tagname-and-classname
+    // and https://stackoverflow.com/questions/11502563/jquery-id-tag-vs-id-findtag-which-is-preferable
+    //var title_nodes = document.querySelectorAll('span#build-title');
+    var title_nodes = document.querySelectorAll('div.buildInfo.newTitleLeft');
+    console.log(title_nodes);
+    if (title_nodes.length == 1) {
+        var build_name = title_nodes[0].innerText;
+        //console.log(build_name);
+        document.title = document.title + " - " + build_name;
+    }
+    // alternatively, using jQuery: var build_name = $('span#build-title').text();  // how to use $().find('span')?
+})();
\ No newline at end of file