Skip to content

Commit

Permalink
Merge branch 'oujs-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Martii committed Oct 18, 2019
2 parents 5134052 + be98c56 commit 110aa89
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/oujs/OUJS-1/OUJS-1.user.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ==UserScript==
// @name OUJS-1
// @namespace https://openuserjs.org/users/Marti
// @description Pending rewrite
// @description Small changes to OUJS that may or may not make it upstream
// @copyright 2016+, Marti Martz, (https://openuserjs.org/users/Marti)
// @copyright 2014-2016, TimidScript
// @copyright 2013+, OpenUserJS Group (https://github.com/OpenUserJs)
// @license CC-BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
// @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @version 2.0.0a.9
// @version 2.0.0a.10
// @icon https://gravatar.com/avatar/7ff58eb098c23feafa72e0b4cd13f396?s=48

// @author Marti
Expand Down Expand Up @@ -87,6 +87,11 @@
"type": 'checkbox',
"label": 'More emphasis on current username',
"default": false
},
'stickMainNav': {
"type": 'checkbox',
"label": 'Main navigation to sticky',
"default": false
}
},
css:
Expand Down Expand Up @@ -209,11 +214,25 @@

var ownerNodes = document.querySelectorAll('span.label');
for (var i = 0; i < ownerNodes.length; ++i) {
if (ownerNodes[i].firstChild.textContent === usernameNode.textContent) {
if (ownerNodes[i].firstChild && ownerNodes[i].firstChild.textContent === usernameNode.textContent) {
ownerNodes[i].classList.remove('label-info');
ownerNodes[i].classList.add('label-primary');
}
}
}

if (gmc.get('stickMainNav')) {

var nodeStyle = document.createElement('style');
nodeStyle.setAttribute("type", "text/css");
nodeStyle.textContent = '.sticky { position: sticky; top: 0; }';

document.head.appendChild(nodeStyle);

var bodynavNode = document.querySelector('body nav');
if (bodynavNode) {
bodynavNode.classList.add('sticky');
}
}

})();

0 comments on commit 110aa89

Please sign in to comment.