// ==UserScript==
// @title nishino_ameblo_add
// @name nishino_ameblo_add
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://ameblo.jp/nishino-akihiro*
// @grant none
// @require https://code.jquery.com/jquery-1.12.4.js
// @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
// ==/UserScript==
var reg = /[\u3040-\u30ff]/;
var tmp3 = [];
for (var k = 0; k < $("#entryBody a").length; k++) {
var tmp2 = $("#entryBody a").eq(k).attr("href");
if (reg.test(tmp2)) {
$("#entryBody a").eq(k).addClass("akan");
}
tmp3[k] = $("#entryBody a").eq(k).attr("href");
}
for (var j = 0; j < $("#entryBody>*:not(.div_br)").length; j++) {
if ($("#subA").width() / $("#subA").parent().outerWidth(true) < 0.357) {
if ($("#entryBody>*:not(.div_br)").eq(j).text().length < 70) {
$("#entryBody>*:not(.div_br)").eq(j).addClass("e");
}
} else {
if ($("#entryBody>*:not(.div_br)").eq(j).text().length < 60) {
$("#entryBody>*:not(.div_br)").eq(j).addClass("e");
}
}
}
$('.i_pic.e,.div_iframe.e,.waku.e,br.e').removeClass("e");
$('.skin-entryBody img[alt]').attr('alt', function () {
var tmp_alt = $(this).attr('alt');
tmp_alt = tmp_alt.replace("【", "「");
tmp_alt = tmp_alt.replace("】", "」");
return tmp_alt;
});
$(".skin-entryBody *:contains('━')").html(function (_, html) {
return html.replace(/(━+)/g, '<div class="line">$1</div>');
});
$(".skin-entryBody *:contains('=')").html(function (_, html) {
return html.replace(/(={2,})/g, '<div class="line">$1</div>');
});
$(".skin-entryBody *:contains('=')").html(function (_, html) {
return html.replace(/(={2,})/g, '<div class="line">$1</div>');
});
$(".skin-entryBody *:contains('〓')").html(function (_, html) {
return html.replace(/(〓+)/g, '<div class="line">$1</div>');
});
$(".skin-entryBody *:contains('▼')").html(function (_, html) {
return html.replace(/(▼)/g, '<span class="mark">$1</span>');
});
$(".skin-entryBody *:contains('|')").html(function (_, html) {
return html.replace(/(\|)/g, '<span class="mark">$1</span>');
});
$(".skin-entryBody *:contains('【')").html(function (_, html) {
return html.replace(/(【)/g, '<span class="mark">$1</span>');
});
$(".skin-entryBody *:contains('↓')").html(function (_, html) {
return html.replace(/(↓)/g, '<span class="mark">$1</span>');
});
$(".skin-entryBody *:contains(')')").html(function (_, html) {
return html.replace(/(\))/g, '<span class="mark">$1</span>');
});
$(".skin-entryBody *:contains('、')").html(function (_, html) {
return html.replace(/(、)/g, '<span class="ten">$1</span>');
});
$('.skin-entryBody>div:has(.line),.skin-entryBody>p:has(.line)').addClass("l_yoko");
$('.sand_text:has(.line),.n_text:has(.line)').addClass("sand_yoko");
$('.sand_yoko>.line').contents().unwrap();
$('.sand_text:has(.mark),.n_text:has(.mark)').addClass("sand_tate");
$('.i_ren:has(.sand_yoko.sand_span_first),.sand:has(.sand_yoko.sand_span_first)').addClass("sand_first_yoko");
$('.i_ren:has(.sand_tate.sand_span_first),.sand:has(.sand_tate.sand_span_first)').addClass("sand_first_tate");
$('.i_ren:has(.sand_span_last.sand_yoko),.sand:has(.sand_span_last.sand_yoko)').addClass("sand_last_yoko");
$('.i_ren:has(.sand_span_last.sand_tate),.sand:has(.sand_span_last.sand_tate)').addClass("sand_last_tate");
$('.sand_span_first.sand_span_last').removeClass("sand_span_first sand_span_last");
var result3 = document.evaluate('//span[@class="mark"]/preceding-sibling::text()', document, null, 7, null);
for (var z = 0; z < result3.snapshotLength; z++) {
if (/\s/g.test(result3.snapshotItem(z).nodeValue)) {
result3.snapshotItem(z).nodeValue = result3.snapshotItem(z).nodeValue.replace(/\s/g, "");
}
}
$('.skin-entryBody>div:has(.mark),.skin-entryBody>p:has(.mark),.i_ren:has(.mark)').each(function () {
if ($(this).text().length - $(this).find('mark').text().length < 2) {
$(this).addClass("mark_only");
}
});
var result2 = document.evaluate('id("entryBody")/*[self::div or self::p][.//span[@class="mark"][last()][not(./following-sibling::* or string-length(./following-sibling::text())>0)]]', document, null, 7, null);
for (var g = 0; g < result2.snapshotLength; g++) {
result2.snapshotItem(g).classList.add("mark_end");
}
var result8 = document.evaluate('id("entryBody")/*[self::div or self::p or contains(@class,"i_ren")][.//span[@class="mark"][1][not(./preceding-sibling::* or string-length(./preceding-sibling::text())>1)]]', document, null, 7, null);
for (var e = 0; e < result8.snapshotLength; e++) {
result8.snapshotItem(e).classList.add("l_tate");
}
$('.div_br').not('.div_br+.div_br').each(function(){
$(this).nextUntil(':not(.div_br)').andSelf().wrapAll('<div class="div_ren"></div>');
});
$('.div_ren+.e+.div_ren').prev().addClass("solo");
$('.i_ren.solo+.div_ren+.i_ren,.i_ren.solo_a+.div_ren+.i_ren,.i_ren.sand_last_tate+.div_ren+.i_ren').prev().prev().addClass("rail");
$('.l_tate.mark_end').removeClass("mark_end");
$('.l_yoko.l_tate').removeClass("l_tate");
var result6 = document.evaluate('//div[@class="line"]/following-sibling::text()|//div[@class="line"]/preceding-sibling::text()', document, null, 7, null);
for (var b = 0; b < result6.snapshotLength; b++) {
if (/(\s| )/g.test(result6.snapshotItem(b).nodeValue)) {
result6.snapshotItem(b).nodeValue = result6.snapshotItem(b).nodeValue.replace(/\s|\u00A0/g, "");
}
}
$('.sand.l_yoko,.sand.l_tate').removeClass("l_yoko l_tate");
$('.l_yoko,.sand_first_yoko').prev().filter('.div_ren').prev().addClass("sun");
$('.l_tate,.sand_first_tate').prev().filter('.div_ren').prev().addClass("cloud");
$('.sand_last_yoko+.div_ren+.sand_first_tate').addClass("midasi");
$('.l_yoko.solo,.l_tate.solo,.sun.solo,.cloud.solo,.node_last.solo,.solo_a.solo').removeClass("solo");
$('.div_ren').contents().unwrap();
$("a.i_pic:not(.card)").draggable();
$("a.i_pic:not(.card)").on("dragstop", function (event, ui) {
$(this).css('display', 'none');
$(this).after('<div class="revert"><a href="javascript:void(0)">この画像を表示する</a></div>');
});
$(document).on('click', '.revert>a:first-child', function () {
$(this).parent().prev().filter('.rail').css('display', 'block');
$(this).parent().prev().filter('*:not(.rail)').css('display', 'inline');
$(this).parent().remove();
});
var sameArr = tmp3.filter(function (p, q, self) {
return self.indexOf(p) === q && q !== self.lastIndexOf(p);
});
for (var m = 0; m < $("#entryBody a").length; m++) {
for (var n = 0; n < sameArr.length; n++) {
if ($("#entryBody a").eq(m).attr("href") == sameArr[n]) {
$("#entryBody a").eq(m).addClass(function (index) {
return "dup" + n;
});
}
}
}
var c = 0;
while (sameArr.length > 0) {
$('.dup' + c).eq(0).removeClass("dup" + c);
c++;
sameArr.shift();
}
$('table.i_pic a').removeClass();
var result5 = document.evaluate('id("entryBody")//a[contains(@class,"dup")][not(starts-with(@href,"https://ameblo.jp/nishino-akihiro/image"))]', document, null, 7, null);
for (var f = 0; f < result5.snapshotLength; f++) {
result5.snapshotItem(f).classList.add("dup");
}
function size_origin() {
$('.div_iframe').toggleClass("iframe-wrap");
}
$('#blogSearchInputHeader')[0].addEventListener('focus', size_origin, false);
$('.skin-blogBody')[0].addEventListener('dblclick', size_origin, false);