NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name LinkedIn Wide & Auto Dark Mode
// @version 0.7
// @icon https://static.licdn.com/scds/common/u/images/logos/favicons/v1/favicon.ico
// @description Show a wide LinkedIn page and automatically shows dark colors during night time.
// @author navchandar
// @match https://www.linkedin.com/*
// @match http://*linkedin.com/*
// @run-at document-start
// @license MIT
// @updateURL https://openuserjs.org/meta/navchandar/LinkedIn_Wide_Auto_Dark_Mode.meta.js
// @copyright 2018, navchandar (https://openuserjs.org/users/navchandar)
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
//--- Page-specific function to do what we want when the node is found.
function commentCallbackFunction (jNode) {
jNode.text ("This comment changed by waitForKeyElements().");
}
IMPORTANT: This function requires your script to have loaded jQuery.
*/
function waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector) {
var targetNodes, btargetsFound;
if (typeof iframeSelector == "undefined")
targetNodes = $(selectorTxt);
else
targetNodes = $(iframeSelector).contents()
.find(selectorTxt);
if (targetNodes && targetNodes.length > 0) {
btargetsFound = true;
/*--- Found target node(s). Go through each and act if they
are new.
*/
targetNodes.each(function () {
var jThis = $(this);
var alreadyFound = jThis.data('alreadyFound') || false;
if (!alreadyFound) {
//--- Call the payload function.
var cancelFound = actionFunction(jThis);
if (cancelFound)
btargetsFound = false;
else
jThis.data('alreadyFound', true);
}
});
}
else {
btargetsFound = false;
}
//--- Get the timer-control variable for this selector.
var controlObj = waitForKeyElements.controlObj || {};
var controlKey = selectorTxt.replace(/[^\w]/g, "_");
var timeControl = controlObj[controlKey];
//--- Now set or clear the timer as appropriate.
if (btargetsFound && bWaitOnce && timeControl) {
//--- The only condition where we need to clear the timer.
clearInterval(timeControl);
delete controlObj[controlKey]
}
else {
//--- Set a timer, if needed.
if (!timeControl) {
timeControl = setInterval(function () {
waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector);
}, 300);
controlObj[controlKey] = timeControl;
}
}
waitForKeyElements.controlObj = controlObj;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleepFunc() {
await sleep(3000);
}
function HomePage(jNode) {
setTimeout(function () {
sleepFunc();
var elem = document.querySelector('#voyager-feed > div.neptune-grid.three-column.ghost-animate-in > div');
elem.style.width = '80%';
var elem1 = document.querySelector('#voyager-feed > div.neptune-grid.three-column.ghost-animate-in > aside.right-rail');
elem1.parentNode.removeChild(elem1);
var elem2 = document.querySelector('#voyager-feed > div.neptune-grid.three-column.ghost-animate-in > aside.left-rail');
elem2.parentNode.removeChild(elem2);
}, 1000)
}
function MyNetwork(jNode) {
setTimeout(function () {
sleepFunc();
var elem = document.querySelector('#mynetwork > div > div.neptune-grid.three-column.ghost-animate-in > div');
elem.style.width = '80%';
var elem1 = document.querySelector('#mynetwork > div > div.neptune-grid.three-column.ghost-animate-in > aside.right-rail');
elem1.parentNode.removeChild(elem1);
var elem2 = document.querySelector('#mynetwork > div > div.neptune-grid.three-column.ghost-animate-in > aside.left-rail');
elem2.parentNode.removeChild(elem2);
}, 1000)
}
function Profile(jNode) {
setTimeout(function () {
sleepFunc();
var elem = document.querySelector('#profile-wrapper > div.pv-content.profile-view-grid.neptune-grid.two-column.ghost-animate-in.pv-content--touch-device > div.core-rail');
elem.style.width = '80%';
var elem1 = document.querySelector('#profile-wrapper > div.pv-content.profile-view-grid.neptune-grid.two-column.ghost-animate-in.pv-content--touch-device > div.pv-content__right-rail.right-rail');
elem1.parentNode.removeChild(elem1);
}, 1000)
}
(function () {
'use strict';
var css = document.createElement('style');
css.type = "text/css";
css.innerHTML = "body { color: Snow !important; background-color: #0f1d26 !important; }\
a { color: Snow !important; background-color: #0f1d26 !important; } \
div, artdeco-tab { color: #0073b1; background-color: #0f1d26 !important; }\
p { color: snow !important; background-color: #0f1d26 !important; }\
nav { color: lightgrey !important; background-color: #0f1d26 !important; }\
input { color: lightgrey !important; background-color: #0f1d26 !important; }\
label { color: lightgrey !important; background-color: #0f1d26 !important; }\
header { color: lightgrey !important; background-color: #0f1d26 !important; }\
button, textarea { color: lightgrey !important; }\
span { color: Snow !important; background-color: #0f1d26 !important; }\
#mynetwork-nav-item > a > span.nav-item__badge > span.nav-item__badge-count { background-color: #ff2c33 !important; }\
#jobs-nav-item > a > span.nav-item__badge > span.nav-item__badge-count { background-color: #ff2c33 !important; }\
#messaging-nav-item > a > span.nav-item__badge > span.nav-item__badge-count { background-color: #ff2c33 !important; }\
#notifications-nav-item > a > span.nav-item__badge > span.nav-item__badge-count { background-color: #ff2c33 !important; }\
#profile-nav-item > a > span.nav-item__badge > span.nav-item__badge-count { background-color: #ff2c33 !important; }\
h1, h2, h3, h4, h5, h6 { color: Snow !important; background-color: #0f1d26 !important; }\
ui, li, section { color: Snow !important; background-color: #0f1d26 !important; }\
dt, dd, input, blockquote, article, artdeco-modal, time, footer { color: Snow !important; background-color: #0f1d26 !important; }\
.organization-outlet .org-about-company-module__show-details-button { background-color: #001d26; border-top: 1px solid rgba(0,0,0,.15); box-sizing: border-box; line-height: 32px;}\
";
var d = new Date(); // for now
var time = d.getHours();
if (time >= 20 || time < 8) {
// Run this only @ night
document.getElementsByTagName('head')[0].appendChild(css);
}
sleep(5000);
waitForKeyElements("#voyager-feed > div.neptune-grid.three-column.ghost-animate-in > aside.left-rail", HomePage);
waitForKeyElements("#mynetwork > div > div.neptune-grid.three-column.ghost-animate-in > aside.left-rail", MyNetwork);
waitForKeyElements("#profile-wrapper > div.pv-content.profile-view-grid.neptune-grid.two-column.ghost-animate-in.pv-content--touch-device > div.core-rail", Profile);
})();