nishino_ameblo_kdiv

    
      
  • // ==UserScript==
    // @name         nishino_ameblo_kdiv
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  try to take over the world!
    // @author       You
    // @match        https://ameblo.jp/nishino-akihiro/entry*
    // @match        https://gamp.ameblo.jp/nishino-akihiro/entry*
    // @grant        none
    // ==/UserScript==
    while (document.getElementById("test2") == null) {
      var result = document.evaluate('//div[@class="skin-entryBody" or @class="entry-text"]//*[not(./*)][not(self::br) and  not(self::img) and  not(self::iframe) and not(self::amp-img)]', document, null, 7, null);
      var result5 = document.evaluate('//div[@class="skin-entryBody" or @class="entry-text"]//*[not(./*)][not(self::br) and  not(self::img) and  not(self::iframe) and not(self::amp-img)]/text()', document, null, 7, null);
      for (var i = 0; i < result5.snapshotLength; i++) {
        //ゼロ幅スペース削除
        result5.snapshotItem(i).nodeValue = result5.snapshotItem(i).nodeValue.replace(/\u200B/g, "");
        //連続スペースを全角スペースに
        result5.snapshotItem(i).nodeValue = result5.snapshotItem(i).nodeValue.replace(/\s\s+/g, ' ');
        //全角スペース判定で改行とみなす
        if (/ /g.test(result5.snapshotItem(i).nodeValue)) {
          result.snapshotItem(i).classList.add("div_br");
        }
        //半角スペース判定でスペース削除
        else if (/ /g.test(result5.snapshotItem(i).nodeValue)) {
          result5.snapshotItem(i).nodeValue = result5.snapshotItem(i).nodeValue.replace(/\s/g, '');
        }
        result.snapshotItem(i).dataset.content = result5.snapshotItem(i).nodeValue;
        /*if(result.snapshotItem(i).dataset.content=="")
        {
            result.snapshotItem(i).remove();
        }*/
      }
      var result2 = document.evaluate('descendant::div[@data-content][1]', document, null, 7, null);
      result2.snapshotItem(0).id = "test2";
    }
    //改行クラスを持たずにスペースのあるタグ削除
    var result4 = document.evaluate('//*[not(@class="div_br")][@data-content]', document, null, 7, null)
    for (var k = 0; k < result4.snapshotLength; k++) {
      if (/\s/g.test(result4.snapshotItem(k).firstChild.nodeValue)) {
        result4.snapshotItem(k).remove();
      }
    }
    //テキスト中のスぺースの場合改行クラス削除
    var result3 = document.evaluate('//*[@class="div_br"][string-length(@data-content)>1]', document, null, 7, null)
    for (var j = 0; j < result3.snapshotLength; j++) {
      result3.snapshotItem(j).classList.remove("div_br");
    }
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/10/30 20:10:55 - 2018-10-30
  2. 2018/10/30 20:09:09 - 2018-10-30