Last active
August 29, 2015 14:21
-
-
Save Niceblack/0353c75f4314ef51acee to your computer and use it in GitHub Desktop.
Добавление "похожие публикации" и "что обсуждают" под спойлер
This file contains 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 HabrGeekMega Spoiler block_after_post | |
// @namespace HabrGeekMega | |
// @description Добавление "похожие публикации" и "что обсуждают" под спойлер | |
// @include http://habrahabr.ru/* | |
// @include http://geektimes.ru/* | |
// @include http://megamozg.ru/* | |
// @version 1.1 | |
// @grant none | |
// ==/UserScript== | |
// Меняем | |
// <div class="block_after_post"> | |
// <div class="similar_posts"> // <div class="live_broadcast"> | |
// <h2 class="title"> | |
// <div class="posts_list"> | |
// на | |
// <div id="placeholder" class="hidden html_format" style="display: block;"> | |
// <div class="spoiler"> | |
// <b class="spoiler_title> | |
// <div class="spoiler_text" style="display: none;> | |
function changeBlock(link0_name) { | |
function restore() { | |
link.outerHTML = backup | |
} | |
var link = document.querySelector('.block_after_post') | |
if (!link) return | |
var backup = link.outerHTML | |
link.setAttribute('id', 'placeholder') | |
link.setAttribute('class', 'hidden html_format') | |
var linkStyle = 'margin-top: 20px;' | |
link.setAttribute('style', 'display: block;' + linkStyle) | |
var link0 = link.querySelector(link0_name) | |
if (!link0) { restore(); return } | |
link0.setAttribute('class', 'spoiler') | |
var link00 = link0.querySelector('.title') | |
if (!link00) { restore(); return } | |
link00.setAttribute('class', 'spoiler_title') | |
link00.outerHTML = link00.outerHTML.replace(/h2/g, 'b') | |
var link01 = link0.querySelector('.posts_list') | |
if (!link01) { restore(); return } | |
link01.setAttribute('class', 'spoiler_text') | |
link01.setAttribute('style', 'display: none;') | |
} | |
// Похожие публикации | |
changeBlock('.similar_posts') | |
// Что обсуждают | |
changeBlock('.live_broadcast') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment