rosenrot/plugins/style/style.js

134 lines
3.9 KiB
JavaScript
Raw Normal View History

// Replicates the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/>
2023-02-15 02:24:47 +00:00
var styles = null;
if (document.domain == "forum.effectivealtruism.org"){
2023-02-15 02:24:47 +00:00
styles = `
.Layout-main {
margin-left: 100px;
}
.SingleColumnSection-root {
width: 1000px !important;
max-width: 1400px !important;
padding-left: 100px !important;
}
.NavigationStandalone-sidebar {
display: none;
}
.intercom-lightweight-app{
display: none;
}
`
var styleSheet = document.createElement('style')
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
console.log('Style changed')
}
2023-02-11 13:40:15 +00:00
if (document.domain == "mail.proton.me" ){
2023-02-15 02:24:47 +00:00
styles = `
2023-02-11 13:40:15 +00:00
.item-container-row.read, .item-container.read {
background-color: white;
}
.item-container-row.unread, .item-container.unread {
background-color: #E8E8E8;
}
.selection .item-container-row.item-is-selected, .item-container.item-is-selected {
background-color: var(--selection-background-color) !important;
}
`
2023-02-15 02:24:47 +00:00
}
if (document.domain == "forum.nunosempere.com" ){
styles = `
body {
zoom: 0.625 !important;
}
`
}
2023-04-29 22:33:09 +00:00
if (document.domain == "search.nunosempere.com" ){
styles = `
footer {
display: none;
}
`
}
if (document.domain == "twitter.com" ){
styles = `
[data-testid="placementTracking"] {
display: none;
}
[data-testid="sidebarColumn"] {
display: none;
}
`
}
2023-02-15 02:24:47 +00:00
if(styles != null){
2023-02-11 13:40:15 +00:00
var styleSheet = document.createElement('style')
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
console.log('Style changed')
}
// Replace default alert with new function
// whose style can be changed!
2023-06-17 06:29:27 +00:00
window.alert = (message) => {
let alertDiv = document.getElementById('customAlert');
if (!alertDiv) {
2023-06-17 06:29:27 +00:00
const html = `
<div id="customAlert" class="custom-alert">
<div class="custom-alert-content">
<p id="alertMessage"></p>
<button id="alertOkButton">OK</button>
</div>
</div>
<style>
.custom-alert {
display: none;
position: fixed;
z-index: 999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.custom-alert-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
font-family: monospace; /* Use monospace font */
}
.visible {
display: block;
}
</style>
`;
document.body.insertAdjacentHTML('beforeend', html);
alertDiv = document.getElementById('customAlert');
document.getElementById('alertOkButton').onclick = () => {
alertDiv.classList.remove('visible');
document.removeEventListener('keydown', dismissAlert);
};
2023-06-17 06:29:27 +00:00
}
const dismissAlert = (event) => {
if (event.key === 'Enter' /*&& event.ctrlKey*/ && alertDiv.classList.contains('visible')) {
alertDiv.classList.remove('visible');
document.removeEventListener('keydown', dismissAlert);
}
}
2023-06-17 06:29:27 +00:00
document.addEventListener('keydown', dismissAlert);
document.getElementById('alertMessage').textContent = message;
2023-06-17 06:29:27 +00:00
alertDiv.classList.add('visible');
}
// ^ takes 0.014ms to run, so performance is not the concern here.
// timed with console.time, console.timeEnd
2023-06-17 06:29:27 +00:00
document.body.style.visibility = "visible"