Last active
June 21, 2025 12:02
-
-
Save pazoozoo42/267a1c6e8d8720ff1875e7d5bf237c04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Orbitar temporary tweaks | |
// @namespace http://tampermonkey.net/ | |
// @version 1.5.0 | |
// @description Slightly modify orbitar.space UI | |
// @author pazoozoo42 | |
// @match https://orbitar.space/* | |
// @match https://*.orbitar.space/* | |
// @match http://orbitar.local/* | |
// @match http://*.orbitar.local/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=orbitar.space | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
let currentLoggedUsername = null; | |
let currentLoggedUserId = null; | |
const getCookie = function (name) { | |
const value = `; ${document.cookie}`; | |
const parts = value.split(`; ${name}=`); | |
if (parts.length === 2) { | |
return parts.pop().split(';').shift(); | |
} | |
} | |
fetch(document.location.protocol + '//api.' + document.location.host + '/api/v1/status', { | |
'headers': { | |
'content-type': 'application/json', | |
'x-session-id': getCookie('session') | |
}, | |
'body': '{"site":"main"}', | |
'method': 'POST', | |
'mode': 'cors', | |
'credentials': 'omit' | |
}).then(function (response) { | |
return response.json(); | |
}).then(function (responseJson) { | |
currentLoggedUsername = responseJson.payload.user.username; | |
currentLoggedUserId = responseJson.payload.user.id; | |
}).catch(function () { | |
}); | |
const live = function (eventType, elementQuerySelector, cb) { | |
document.addEventListener(eventType, function (event) { | |
const qs = document.querySelectorAll(elementQuerySelector); | |
if (qs) { | |
let el = event.target, index = -1; | |
while (el && ((index = Array.prototype.indexOf.call(qs, el)) === -1)) { | |
el = el.parentElement; | |
} | |
if (index > -1) { | |
cb.call(el, event); | |
} | |
} | |
}); | |
} | |
const getSettings = function () { | |
let currentSettings = {}; | |
try { | |
currentSettings = JSON.parse(localStorage.getItem('BO__SETTINGS')) | |
} catch (e) { | |
} | |
if (currentSettings === null) { | |
currentSettings = {}; | |
} | |
return Object.assign({}, { | |
changeLayout: false, | |
hideCommentsRatings: false, | |
addVocativeToComments: false, | |
wideContent: false | |
}, currentSettings); | |
} | |
const getHidingUsernames = function () { | |
let currentSettings = getSettings(); | |
if (!currentSettings.hide) { | |
return []; | |
} | |
if (currentSettings.hide.length === 1 && currentSettings.hide[0] === '') { | |
return []; | |
} | |
return currentSettings.hide; | |
} | |
const getHidingPosts = function () { | |
let currentSettings = getSettings(); | |
if (!currentSettings.hidePosts) { | |
return []; | |
} | |
if (currentSettings.hidePosts.length === 1 && currentSettings.hidePosts[0] === '') { | |
return []; | |
} | |
return currentSettings.hidePosts; | |
} | |
const doHidePost = function (el, author, site) { | |
el.classList.add('BO__hidden_post'); | |
let currentSettings = getSettings(); | |
el.dataset.originalContent = el.innerHTML; | |
el.innerHTML = currentSettings.hidePostsForGood ? '' : '<span>спрятанный пост от ' + author + (site ? (' на ' + site) : '') + '</span>'; | |
} | |
let currentPostAuthor = null; | |
const settings = getSettings(); | |
const hideUsernames = getHidingUsernames(); | |
const hidePosts = getHidingPosts(); | |
let vocativeOpeningTags = []; | |
let vocativeClosingTags = []; | |
if (settings.vocativeBold) { | |
vocativeOpeningTags.push('<b>'); | |
vocativeClosingTags.push('</b>'); | |
} | |
if (settings.vocativeItalic) { | |
vocativeOpeningTags.push('<i>'); | |
vocativeClosingTags.push('</i>'); | |
} | |
const doStuff = function () { | |
if (document.hidden) { | |
return; | |
} | |
document.querySelectorAll('[class*="PostComponent_post__"]').forEach((el) => { | |
if (el.dataset.boProcessed) { | |
return; | |
} | |
const signature = el.querySelector('[class*="SignatureComponent_signature__"]'); | |
if (!signature) { | |
return; | |
} | |
const signaturreLinks = signature.querySelectorAll('a[href*="/p"]'); | |
const signatureSiteLink = signature.querySelector('a[href*="/s"]'); | |
let postSite = null; | |
if (signatureSiteLink && signatureSiteLink.innerHTML) { | |
postSite = signatureSiteLink.innerHTML; | |
} | |
let postId = null; | |
signaturreLinks.forEach((link) => { | |
if (link.href) { | |
let result = link.href.match(/\/(p[0-9]+)/); | |
if (result && result.length >= 2) { | |
postId = result[1]; | |
} | |
} | |
}); | |
if (settings.changeLayout) { | |
const controlsContainer = el.querySelector('[class*=PostComponent_controls__]'); | |
controlsContainer.insertAdjacentElement('afterbegin', signature); | |
} | |
const postAuthor = signature.querySelector('a.i-user').innerText; | |
if (postId) { | |
const hidePostEl = document.createElement('span'); | |
hidePostEl.className = 'BO__hide-post'; | |
hidePostEl.innerHTML = '×'; | |
hidePostEl.dataset.postId = postId; | |
signature.insertAdjacentElement('afterbegin', hidePostEl); | |
} | |
if ( | |
hidePosts.includes(postId) || | |
hideUsernames.includes(postAuthor) || | |
(postSite && hidePosts.includes(postSite)) | |
) { | |
doHidePost(el, postAuthor, postSite); | |
} | |
el.dataset.boProcessed = '1'; | |
}); | |
if (document.location.href.match(/space\/(s\/[a-z0-9_-]+?\/)?p\d+/)) { | |
if (!currentPostAuthor) { | |
let currentPost = document.querySelector('[class*=PostComponent_post__] [class*="SignatureComponent_signature__"] a'); | |
if (currentPost) { | |
let currentPostAuthor = currentPost.textContent || currentPost.innerText; | |
document.querySelectorAll('[class*="CommentComponent_comment__"]').forEach((el) => { | |
let commentAuthorContainer = el.querySelector('[class*=SignatureComponent_signature__] a'); | |
let commentAuthor = commentAuthorContainer.textContent || commentAuthorContainer.innerText; | |
let commentBodyContainer = el.querySelector('[class*="commentBody"]'); | |
let editingThisComment = el.querySelector('[class*="CreateCommentComponent_editor__"]'); | |
let previewingEditedComment = el.querySelector('[class*="CreateCommentComponent_preview__"]'); | |
if (editingThisComment || previewingEditedComment) { | |
commentBodyContainer.classList.add('BO_editing_comment'); | |
} else { | |
commentBodyContainer.classList.remove('BO_editing_comment'); | |
} | |
if (currentPostAuthor === commentAuthor && !commentBodyContainer.className.includes('BO__CommentByAuthor')) { | |
commentBodyContainer.className = commentBodyContainer.className + ' BO__CommentByAuthor'; | |
} | |
if ( | |
currentLoggedUsername && | |
(commentAuthor === currentLoggedUsername) && | |
!commentBodyContainer.className.includes('BO__CommentByLoggedUser') && | |
currentPostAuthor !== commentAuthor | |
) { | |
commentBodyContainer.className = commentBodyContainer.className + ' BO__CommentByLoggedUser'; | |
} | |
if (hideUsernames.includes(commentAuthor)) { | |
commentBodyContainer.classList.add('BO__hidden_comment'); | |
commentBodyContainer.addEventListener('click', function () { | |
commentBodyContainer.classList.remove('BO__hidden_comment'); | |
}); | |
} | |
}); | |
} | |
} | |
if (settings.addVocativeToComments) { | |
document.querySelectorAll('[class*=CommentComponent_answers__] > [class*=CommentComponent_comment__]').forEach(function (el) { | |
let parentComment = el.parentNode.parentNode.querySelector('.commentBody'); | |
if (!parentComment) { | |
return; | |
} | |
let parentCommentAuthorContainer = parentComment.querySelector('[class*=SignatureComponent_signature__] a'); | |
if (!parentCommentAuthorContainer) { | |
return; | |
} | |
let parentCommentAuthor = parentCommentAuthorContainer.innerText; | |
if (!parentCommentAuthor) { | |
return; | |
} | |
let commentHtmlContainer = el.querySelector('.commentBody [class*=CommentComponent_content__] [class*=ContentComponent_content__]'); | |
if ( | |
!commentHtmlContainer || | |
commentHtmlContainer.dataset.vocativeProcessed | |
) { | |
return; | |
} | |
if (commentHtmlContainer.innerHTML.match(new RegExp(`^${parentCommentAuthor}[,:]`))) { | |
return; | |
} | |
const commentStartsWithMedia = commentHtmlContainer.innerHTML.match(/^\s*(<img|<iframe)/); | |
if (settings.vocativeLowercase) { | |
commentHtmlContainer.innerHTML = commentHtmlContainer.innerHTML.charAt(0).toLowerCase() + commentHtmlContainer.innerHTML.slice(1); | |
} | |
commentHtmlContainer.innerHTML = vocativeOpeningTags.join('') | |
+ parentCommentAuthor | |
+ vocativeClosingTags.join('') | |
+ ((settings.vocativeSymbol ? settings.vocativeSymbol : ',') + ' ') | |
+ (commentStartsWithMedia ? '<br/>' : '') | |
+ commentHtmlContainer.innerHTML; | |
commentHtmlContainer.dataset.vocativeProcessed = '1'; | |
}); | |
} | |
} else { | |
currentPostAuthor = null; | |
} | |
if ( | |
document.location.href.match(/\/u\/[^\/]+\/comments/) || | |
document.location.href.match(/profile\/comments/) | |
) { | |
if (settings.addVocativeToComments) { | |
document.querySelectorAll('[class*=UserPage_userinfo__] [class*=FeedPage_feed__] [class*=CommentComponent_comment__]').forEach(function (el) { | |
let parentCommentAuthorNode = el.querySelector('[class=commentBody] [class*=SignatureComponent_signature__]'); | |
if (parentCommentAuthorNode) { | |
const parentCommentAuthor = parentCommentAuthorNode.getElementsByClassName('arrow'); | |
if (parentCommentAuthor && parentCommentAuthor[0]) { | |
const parentCommentAuthorUsername = parentCommentAuthor[0].innerHTML; | |
const commentHtmlContainer = el.querySelector('.commentBody [class*=CommentComponent_content__] [class*=ContentComponent_content__]'); | |
if (!commentHtmlContainer || commentHtmlContainer.dataset.vocativeProcessed) { | |
return; | |
} | |
if (commentHtmlContainer.innerHTML.match(new RegExp(`^${parentCommentAuthor}[,:]`))) { | |
return; | |
} | |
const commentStartsWithMedia = commentHtmlContainer.innerHTML.match(/^\s*(<img|<iframe)/); | |
if (settings.vocativeLowercase) { | |
commentHtmlContainer.innerHTML = commentHtmlContainer.innerHTML.charAt(0).toLowerCase() + commentHtmlContainer.innerHTML.slice(1); | |
} | |
commentHtmlContainer.innerHTML = vocativeOpeningTags.join('') | |
+ parentCommentAuthorUsername | |
+ vocativeClosingTags.join('') | |
+ ((settings.vocativeSymbol ? settings.vocativeSymbol : ',') + ' ') | |
+ (commentStartsWithMedia ? '<br/>' : '') | |
+ commentHtmlContainer.innerHTML; | |
commentHtmlContainer.dataset.vocativeProcessed = '1'; | |
} | |
} | |
}); | |
} | |
} | |
} | |
const targetNode = document.getElementsByTagName('html')[0]; | |
const config = {attributes: false, childList: true, subtree: true}; | |
let previousUrl = ''; | |
const callback = function () { | |
doStuff(); | |
if (settings.redirectToAll) { | |
const homeLogo = document.querySelector('[class*="Topbar_left__"] a[href="/"]'); | |
if (homeLogo) { | |
homeLogo.setAttribute('href', '/all'); | |
} | |
if (location.href !== previousUrl) { | |
if (location.href === document.location.protocol + '//' + document.location.host + '/') { | |
document.location.href = document.location.protocol + '//' + document.location.host + '/all'; | |
return; | |
} | |
previousUrl = location.href; | |
} | |
} | |
}; | |
const observer = new MutationObserver(callback); | |
observer.observe(targetNode, config); | |
doStuff(); | |
let settingsShown = false; | |
live('click', '.BO__settings button.remove-main', function (e) { | |
const stateIndicator = document.getElementById('BO__main_change_state'); | |
stateIndicator.innerHTML = ''; | |
try { | |
fetch(document.location.protocol + '//api.' + document.location.host + '/api/v1/site/subscribe', { | |
'headers': { | |
'content-type': 'application/json', | |
'x-session-id': getCookie('session') | |
}, | |
'body': '{"site":"main", "main":' + !!e.target.dataset.value + '}', | |
'method': 'POST', | |
'mode': 'cors', | |
'credentials': 'omit' | |
}).then(function (response) { | |
return response.json(); | |
}).then(function (responseJson) { | |
if (responseJson.result === 'success') { | |
stateIndicator.innerHTML = 'готово'; | |
} | |
}).catch(function () { | |
}); | |
} catch (e) { | |
} | |
}); | |
live('click', '.BO__settings button.save', function (e) { | |
let newSettings = { | |
hide: document.querySelector('.BO__settings textarea.usernames').value.split(/\s*,\s*/), | |
hidePosts: document.querySelector('.BO__settings textarea.posts').value.split(/\s*,\s*/), | |
hidePostsForGood: document.querySelector('[data-setting-name="hidePostsForGood"]').checked, | |
changeLayout: document.querySelector('[data-setting-name="changeLayout"]').checked, | |
redirectToAll: document.querySelector('[data-setting-name="redirectToAll"]').checked, | |
fixImages: document.querySelector('[data-setting-name="fixImages"]').checked, | |
hideCommentsRatings: document.querySelector('[data-setting-name="hideCommentsRatings"]').checked, | |
addVocativeToComments: document.querySelector('[data-setting-name="addVocativeToComments"]').checked, | |
vocativeBold: document.querySelector('[data-setting-name="vocativeBold"]').checked, | |
vocativeItalic: document.querySelector('[data-setting-name="vocativeItalic"]').checked, | |
vocativeLowercase: document.querySelector('[data-setting-name="vocativeLowercase"]').checked, | |
vocativeSymbol: document.querySelector('input[name=vocativeSymbol]:checked').getAttribute('data-setting-value'), | |
useFont: document.querySelector('select[name=useFont]').value, | |
wideContent: document.querySelector('[data-setting-name="wideContent"]').checked | |
}; | |
localStorage.setItem('BO__SETTINGS', JSON.stringify(newSettings)); | |
document.querySelector('.BO__settings').remove(); | |
document.getElementById('root').classList.remove('BO__settings_shown'); | |
settingsShown = false; | |
if (e.target.dataset.reload) { | |
document.location.reload(); | |
} | |
}); | |
live('click', '[class*=App_monster__]', function () { | |
if (!settingsShown) { | |
const settingsContainer = document.createElement('div'); | |
settingsContainer.className = 'BO__settings'; | |
settingsContainer.innerHTML = ` | |
<div style="overflow: auto; padding-bottom: 120px;"> | |
<div> | |
<h2>Прятать пользователей (юзернеймы через запятую):</h2> | |
<textarea class="usernames">` + (getHidingUsernames().join(', ')) + `</textarea> | |
</div> | |
<hr/> | |
<div> | |
<h2>Прятать посты (id постов или названия сайтов через запятую):</h2> | |
<textarea class="posts">` + (getHidingPosts().join(', ')) + `</textarea> | |
<div style="margin-bottom: 10px;"> | |
<label><input type="checkbox" data-setting-name="hidePostsForGood" ` + (settings.hidePostsForGood ? 'checked="1"' : '') + ` /> - прятать посты насовсем (если выключено, в ленте будут ссылки на скрытые посты)</label> | |
</div> | |
</div> | |
<hr/> | |
<div class="BO_settings_checkboxes"> | |
<div> | |
<label><input type="checkbox" data-setting-name="redirectToAll" ` + (settings.redirectToAll ? 'checked="1"' : '') + ` /> - редиректить ленту на /all (все посты)</label> | |
</div> | |
<div> | |
<label><input type="checkbox" data-setting-name="changeLayout" ` + (settings.changeLayout ? 'checked="1"' : '') + ` /> - менять стили</label> | |
</div> | |
<div> | |
<label> <input type="checkbox" data-setting-name="fixImages" ` + (settings.fixImages ? 'checked="1"' : '') + ` /> - исправлять висячие картинки и видео</label> | |
</div> | |
<div> | |
<label><input type="checkbox" data-setting-name="hideCommentsRatings" ` + (settings.hideCommentsRatings ? 'checked="1"' : '') + ` /> - прятать рейтинг комментов</label> | |
</div> | |
<div> | |
<label><input type="checkbox" data-setting-name="wideContent" ` + (settings.wideContent ? 'checked="1"' : '') + ` /> - сделать контент пошире</label> | |
</div> | |
<div> | |
<label><input type="checkbox" data-setting-name="addVocativeToComments" ` + (settings.addVocativeToComments ? 'checked="1"' : '') + ` /> - добавлять обращение в комменты</label> | |
</div> | |
<div> | |
<label> <input type="checkbox" data-setting-name="vocativeBold" ` + (settings.vocativeBold ? 'checked="1"' : '') + ` /> - выделять обращение <b>жирным</b></label> | |
</div> | |
<div> | |
<label> <input type="checkbox" data-setting-name="vocativeItalic" ` + (settings.vocativeItalic ? 'checked="1"' : '') + ` /> - выделять обращение <i>курсивом</i></label> | |
</div> | |
<div> | |
<label> <input type="checkbox" data-setting-name="vocativeLowercase" ` + (settings.vocativeLowercase ? 'checked="1"' : '') + ` /> - уменьшать первую букву после обращения</label> | |
</div> | |
<div> | |
<label> <input name="vocativeSymbol" type="radio" data-setting-name="vocativeSymbol" data-setting-value="," ` + (settings.vocativeSymbol === ',' || !settings.vocativeSymbol ? 'checked="1"' : '') + ` /> - отделять обращение запятой</label> | |
</div> | |
<div> | |
<label> <input name="vocativeSymbol" type="radio" data-setting-name="vocativeSymbol" data-setting-value=":" ` + (settings.vocativeSymbol === ':' ? 'checked="1"' : '') + ` /> - отделять обращение двоеточием</label> | |
</div> | |
</div> | |
<hr/> | |
<div> | |
<h2 style="display: inline-block;">Использовать шрифт:</h2> | |
<select name="useFont" id="BO__settings_font" class="BO__settings__font"> | |
<option value="">дефолтный</option> | |
<option value="Google Sans">Google Sans</option> | |
<option value="Roboto">Roboto</option> | |
<option value="Roboto Slab">Roboto Slab</option> | |
<option value="Ubuntu">Ubuntu</option> | |
<option value="Rubik">Rubik</option> | |
<option value="Montserrat">Montserrat</option> | |
<option value="Merriweather">Merriweather</option> | |
<option value="Fira Sans">Fira Sans</option> | |
</select> | |
</div> | |
<hr/> | |
<div> | |
<button class="remove-main" data-value="">убрать главную из подписок</button> или | |
<button class="remove-main" data-value="1">вернуть её туда</button><b id="BO__main_change_state" class="BO__ok"></b><br/> | |
<i>изменения вступят в силу после перезагрузки страницы</i> | |
</div> | |
</div> | |
<div style="position: absolute; bottom: 10px;"> | |
<div> | |
<button class="save" data-reload="1">сохранить и перезагрузить страницу</button> | |
</div> | |
<div> | |
<i>для вступления в силу надо перезагрузить страницу после сохранения</i> | |
</div> | |
</div> | |
`; | |
document.getElementsByTagName('body')[0].appendChild(settingsContainer); | |
settingsShown = true; | |
document.getElementById('BO__settings_font').value = settings.useFont; | |
document.getElementById('root').classList.add('BO__settings_shown'); | |
} else { | |
settingsShown = false; | |
if (document.querySelector('.BO__settings')) { | |
document.querySelector('.BO__settings').remove(); | |
} | |
document.getElementById('root').classList.remove('BO__settings_shown'); | |
} | |
}); | |
live('click', '.BO__hide-post', function (e) { | |
const settings = getSettings(); | |
let hidePosts = settings.hidePosts; | |
if (!hidePosts || (hidePosts.length === 1 && hidePosts[0] === '')) { | |
hidePosts = []; | |
} | |
const postId = e.target.dataset.postId; | |
if (postId && !hidePosts.includes(postId)) { | |
hidePosts.push(postId); | |
settings.hidePosts = hidePosts; | |
localStorage.setItem('BO__SETTINGS', JSON.stringify(settings)); | |
} | |
const post = e.target.parentNode.parentNode.parentNode; | |
if (post) { | |
doHidePost(post); | |
} | |
}); | |
live('click', '.BO__hidden_post span', function (e) { | |
const post = e.target.parentNode; | |
if (!post) { | |
return; | |
} | |
post.classList.remove('BO__hidden_post'); | |
post.innerHTML = post.dataset.originalContent; | |
}); | |
const layoutChangeCss = (settings.useFont ? ` | |
* { | |
font-family: "${settings.useFont}" !important; | |
} | |
` : ``) | |
+ | |
` | |
div[class*=Topbar_topbar__] { | |
--background-color: var(--bg); | |
} | |
.i-user { | |
font-weight: bold !important; | |
} | |
.i-user:before { | |
content: ''; | |
} | |
[class*="PostComponent_post__"] [class*="PostComponent_controls__"] { | |
display: flex; | |
flex-direction: row-reverse; | |
flex-wrap: wrap-reverse; | |
} | |
[class*="PostComponent_optionsList__"] { | |
left: 0; | |
top: 26px; | |
} | |
[class*="PostComponent_post__"] [class*="PostComponent_controls__"] [class*="SignatureComponent_signature__"] { | |
order: 1; | |
margin-bottom: 0 !important; | |
margin-left: 6px; | |
flex-grow: 1; | |
} | |
[class*="CommentComponent_comment__"] .commentBody { | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: space-between; | |
} | |
[class*="CommentComponent_comment__"] [class^="CommentComponent_controls__"] { | |
display: inline-flex; | |
order: 3; | |
flex-direction: row-reverse; | |
font-size: 14px !important; | |
margin-top: -4px; | |
visibility: ` + (settings.hideCommentsRatings ? 'hidden' : '') + `; | |
margin-bottom: -10px; | |
} | |
[class*="CommentComponent_comment__"] [class*="CommentComponent_controls__"] [class*="CommentComponent_control__"] { | |
margin-right: 0; | |
margin-left: 10px; | |
} | |
[class*="CommentComponent_comment__"] [class*="CommentComponent_controls__"] [class*="CommentComponent_control__"] button, | |
[class*="CommentComponent_comment__"] [class*="CommentComponent_controls__"] [class*="CommentComponent_control__"] div | |
{ | |
font-size: 12px; | |
} | |
[class*="CommentComponent_comment__"] .commentBody:hover [class*="CommentComponent_controls__"] { | |
visibility: visible; | |
} | |
[class*="CommentComponent_comment__"] .commentBody [class*="SignatureComponent_signature__"] { | |
margin-top: 5px; | |
order: 2; | |
display: inline-flex; | |
} | |
[class*="CommentComponent_comment__"] .commentBody [class*="SignatureComponent_signature__"], | |
[class*="CommentComponent_comment__"] .commentBody [class*="SignatureComponent_signature__"] [class*="SignatureComponent_toggleHistory__"] | |
{ | |
font-size: 12px; | |
margin-bottom: 0; | |
} | |
[class*="CommentComponent_comment__"] .commentBody [class*="CommentComponent_content__"] { | |
order: 1; | |
flex-basis: 100%; | |
} | |
[class*="CommentComponent_answers__"] { | |
border-left: none; | |
} | |
[class*=".CommentComponent_answers__"] { | |
margin-top: -4px; | |
} | |
.commentBody { | |
padding-left: 4px; | |
} | |
.BO__CommentByAuthor { | |
--background-color: var(--topbar-bg); | |
border-left: 2px solid var(--positive) !important; | |
} | |
.BO__CommentByLoggedUser { | |
border-left: 2px solid var(--danger) !important; | |
} | |
.isNew { | |
border-left: 0; | |
} | |
.isNew .commentBody { | |
border-left: 2px solid var(--primary); | |
} | |
[class*="SignatureComponent_signature__"] { | |
margin-bottom: -4px; | |
} | |
` + (settings.fixImages ? ` | |
[class*="ContentComponent_content__"] img, | |
[class*="ContentComponent_content__"] iframe, | |
[class*="ContentComponent_content__"] video | |
{ | |
display: block; | |
margin-top: 4px; | |
margin-bottom: 4px; | |
} | |
.BO_editing_comment { | |
flex-direction: column; | |
} | |
` : ''); | |
const settingsCss = ` | |
[class*=App_monster__] { | |
cursor: pointer; | |
z-index: 1000; | |
} | |
#root.BO__settings_shown { | |
opacity: 0.1; | |
} | |
@keyframes slide { | |
from { | |
bottom: -500px; | |
} | |
to { | |
bottom: 24px; | |
} | |
} | |
.BO__settings { | |
width: 420px; | |
height: auto; | |
color: var(--fg); | |
background-color: var(--bg); | |
filter: invert(1); | |
animation-duration: 0.3s; | |
animation-name: slide; | |
bottom: 24px; | |
right: 14px; | |
position: fixed; | |
padding: 10px; | |
} | |
.BO__ok { | |
color: green; | |
filter: invert(1); | |
font-size: x-small; | |
} | |
.BO__settings h2 { | |
font-size: 14px; | |
font-weight: bold; | |
} | |
.BO__settings textarea { | |
width: calc(100% - 20px); | |
height: calc(100% - 200px); | |
margin-bottom: 10px; | |
} | |
.BO__settings label { | |
font-size: 12px; | |
} | |
.BO__settings button { | |
margin: 4px; | |
margin-top: 10px; | |
} | |
.BO__settings i { | |
font-size: 10px; | |
} | |
.BO__settings hr { | |
border: 0; | |
border-bottom: 1px dashed #ccc; | |
background: #999; | |
margin-bottom: 0; | |
margin-top: 0; | |
} | |
.BO__settings .BO_settings_checkboxes { | |
margin-top: 10px; | |
margin-bottom: 10px; | |
} | |
`; | |
const hiddenCss = ` | |
.BO__hidden_comment.commentBody { | |
position: relative; | |
outline: 1px solid var(--danger); | |
border-radius: 5px; | |
cursor: pointer; | |
opacity: 0.2; | |
} | |
.BO__hidden_comment.commentBody:hover { | |
opacity: 1; | |
} | |
.BO__hidden_comment.commentBody > div { | |
opacity: 0; | |
} | |
.BO__hidden_comment:before { | |
content: 'Спрятано. Нажмите, чтобы посмотреть, но там может быть хуй!'; | |
font-size: 10px; | |
position: absolute; | |
display: block; | |
width: 100%; | |
text-align: center; | |
cursor: pointer; | |
top: 50%; | |
left: 0; | |
right: 0; | |
margin: auto; | |
transform: translateY(-50%); | |
opacity: 0.2; | |
} | |
.BO__hidden_comment:hover:before { | |
opacity: 1; | |
} | |
.BO__hide-post { | |
cursor: pointer; | |
} | |
.BO__hidden_post { | |
margin: 0 0 20px; | |
font-size: 10px; | |
opacity: 0.2; | |
cursor: pointer; | |
} | |
.BO__hidden_post:hover { | |
opacity: 1; | |
} | |
`; | |
const wideContentCss = ` | |
@media (min-width: 800px) { | |
div[class*=App_container__] { | |
width: calc(100% - 20px); | |
} | |
div[class*=App_innerContainer__] { | |
padding: 0 0 0 200px; | |
} | |
div[class*=FeedPage_feed__], | |
div[class*=UserPage_container__], | |
div[class*=PostPage_container__] | |
{ | |
max-width: initial; | |
} | |
} | |
`; | |
const vocativesCss = ` | |
div.commentBody div[class*=SignatureComponent_signature__] a.arrow.i.i-arrow { | |
visibility: hidden; | |
width: 10px; | |
} | |
div.commentBody div[class*=SignatureComponent_signature__] a.arrow.i.i-arrow:before { | |
visibility: visible; | |
} | |
`; | |
const css = hiddenCss + '\n' + settingsCss + '\n' + | |
(settings.changeLayout ? layoutChangeCss : '') + '\n' + | |
(settings.wideContent ? wideContentCss : '') + '\n' + | |
(settings.addVocativeToComments ? vocativesCss : '') + '\n'; | |
const head = document.head || document.getElementsByTagName('head')[0]; | |
const style = document.createElement('style'); | |
head.appendChild(style); | |
style.setAttribute('type', 'text/css'); | |
style.appendChild(document.createTextNode(css)); | |
if (settings.useFont) { | |
const link = document.createElement('link'); | |
link.setAttribute('href', 'https://fonts.googleapis.com/css?family=' + settings.useFont); | |
link.setAttribute('rel', 'stylesheet'); | |
head.appendChild(link); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment