-
Notifications
You must be signed in to change notification settings - Fork 10
/
Left-sidebar_in_the_Topbar.user.js
44 lines (42 loc) · 1.78 KB
/
Left-sidebar_in_the_Topbar.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name Left-sidebar in the Topbar
// @description Put the left-sidebar in the topbar.
// @author Makyen
// @namespace MakyenStackExchangeAdjustments
// @match *://*.stackoverflow.com/*
// @match *://*.superuser.com/*
// @match *://*.serverfault.com/*
// @match *://*.askubuntu.com/*
// @match *://*.stackapps.com/*
// @match *://*.mathoverflow.net/*
// @match *://*.stackexchange.com/*
// @exclude *://chat.stackoverflow.com/*
// @exclude *://chat.stackexchange.com/*
// @exclude *://chat.*.stackexchange.com/*
// @exclude *://api.*.stackexchange.com/*
// @exclude *://data.stackexchange.com/*
// @version 2.0.0
// @grant none
// @run-at document-start
// ==/UserScript==
/* globals StackExchange */
(function() {
'use strict';
document.documentElement.classList.add('html__unpinned-leftnav');
let calledSEReady = false;
function toggleLeftNavOnAndOffAgainWhenPossible(count) {
if (typeof StackExchange === 'object' && StackExchange.topbar && typeof StackExchange.topbar.toggleUnpinnedLeftNav === 'function') {
StackExchange.topbar.toggleUnpinnedLeftNav(false);
StackExchange.topbar.toggleUnpinnedLeftNav(true);
} else {
count = count ? count + 1 : 1;
if (!calledSEReady && typeof StackExchange === 'object' && typeof StackExchange.ready === 'function') {
StackExchange.ready(toggleLeftNavOnAndOffAgainWhenPossible);
calledSEReady = true;
} else if (count < 120) {
setTimeout(toggleLeftNavOnAndOffAgainWhenPossible, 100 * (count < 20 ? 1 : 10), count);
}
}
}
toggleLeftNavOnAndOffAgainWhenPossible(1);
})();