Mugenmonkey: put DS3 build name in <title>
authorDariusz Murakowski <murakdar@gmail.com>
Tue, 18 Jul 2017 20:15:19 +0000 (16:15 -0400)
committerDariusz Murakowski <murakdar@gmail.com>
Tue, 18 Jul 2017 20:15:19 +0000 (16:15 -0400)
(Mugenmonkey) Dark Souls 3 build title.user.js [new file with mode: 0644]

diff --git a/(Mugenmonkey) Dark Souls 3 build title.user.js b/(Mugenmonkey) Dark Souls 3 build title.user.js
new file mode 100644 (file)
index 0000000..b8033fd
--- /dev/null
@@ -0,0 +1,28 @@
+// ==UserScript==
+// @name         (Mugenmonkey) Dark Souls 3 build title
+// @namespace    http://tampermonkey.net/
+// @version      0.1
+// @description  append build name to page title
+// @author       Dariusz Murakowski
+// @match        https://mugenmonkey.com/darksouls3/*
+// @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.left');
+    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