anonymous No title
JavaScript
function genid(str) {
  // Base64に変換する版
  return Utilities.base64Encode(Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, Utilities.newBlob("").setDataFromString(str, 'utf8').getBytes())).substr(0, 8);
  // 16進数で得たい場合は以下
  /*
  return Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, Utilities.newBlob("").setDataFromString(str, 'utf8').getBytes()).reduce(function(str,chr){
    chr = (chr < 0 ? chr + 256 : chr).toString(16);
    return str + (chr.length==1?'0':'') + chr;
  },'').substr(0,8);
  */
}

function genidTest() {
  Logger.log(genid("あいう")) // -> 31xYiCaw
  Logger.log(genid("えおか")) // -> 0W//Dj6G
  Logger.log(genid("あいう")) // -> 31xYiCaw
}
anonymous No title
JavaScript
function genid(str) {
  // Base64に変換する版
  return Utilities.base64Encode(Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, str)).substr(0, 8);
  // 16進数で得たい場合は以下
  /*
  return Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, str).reduce(function(str,chr){
    chr = (chr < 0 ? chr + 256 : chr).toString(16);
    return str + (chr.length==1?'0':'') + chr;
  },'').substr(0,8);
  */
}

function genidTest() {
  Logger.log(genid("numa")) // -> DfstCa7v 又は 0dfb2d09
  Logger.log(genid("192")) // -> WKL8btOf 又は 58a2fc6e
  Logger.log(genid("numa")) // -> DfstCa7v 又は 0dfb2d09
}
anonymous No title
JavaScript
import puppeteer from 'puppeteer-core'
const getDefaultOsPath = () => {
    if (process.platform === 'win32') {
        return 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
    } else {
        return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
    }
}
let browser = await puppeteer.launch({
    executablePath: getDefaultOsPath()
}))
anonymous No title
JavaScript
anonymous No title
JavaScript
const number = numbers.filter((number)
anonymous No title
JavaScript
/**
 * ログを取得
 */
const get_data = () => {
  return $('.talk')
    .map(function() {
      if (
        $(this)
          .find('dd p')
          .children('a')
          .attr('href') != null
      ) {
        return {
          id: $(this).attr('id'),
          room_name: $('input[name=room_name]').val(),
          name: $(this)
            .find('dt')
            .text(),
          message: `http://drrrkari.com${$(this)
            .find('dd p')
            .children('a')
            .attr('href')}`,
          kind: 0,
          createdAt: new Date()
        };
      }

      if (
        $(this)
          .attr('class')
          .split(' ')[1] === 'system'
      ) {
        return {
          id: $(this).attr('id'),
          room_name: $('input[name=room_name]').val(),
          name: 'system',
          message: $(this).text(),
          kind: 1,
          createdAt: new Date()
        };
      }

      return {
        id: $(this).attr('id'),
        room_name: $('input[name=room_name]').val(),
        name: $(this)
          .find('dt')
          .text(),
        message: $(this)
          .find('dd p')
          .text(),
        kind: 0,
        createdAt: new Date()
      };
    })
    .get()
    .reverse();
};

/**
 * ローカルストレージに保存
 */
const set_storage = () => {
  get_data().map(m => {
    if (localStorage.getItem(m.id) === null) {
      localStorage.setItem(m.id, JSON.stringify(m));
    }
  });
};

/**
 * ローカルストレージからログを抽出
 */
const get_storage = () => {
  const ng = {
    ['__adm_uid']: '',
    ['OX_net_latency']: '',
    ['criteo_pt_cdb_metrics']: '',
    ['criteo_pt_cdb_metrics_expires']: '',
    ['criteo_silent_mode_expires']: '',
    ['test']: '',
    ['criteo_silent_mode']: '',
    ['undefined']: ''
  };

  let _ret = [];
  for (let i = 0; i < localStorage.length; i++) {
    try {
      const key = localStorage.key(i);
      ng[key] === undefined
        ? _ret.push(JSON.parse(localStorage.getItem(key)))
        : '';
    } catch (e) {}
  }

  return _ret;
};

/**
 * オブザーバー
 */
new MutationObserver(() => {
  set_storage();
}).observe($('#talks').get(0), {
  childList: true
});
anonymous No title
JavaScript
const a = 1;
[...Array(10)].map((m, i) => console.log(i))
console.log(a)
anonymous No title
JavaScript
[...Array(10)].map((m, i) => console.log(i))
anonymous No title
JavaScript
[...Array(10)].map((m, i) => console.log(i);)
anonymous No title
JavaScript
console.log(111)
Don't you submit code?
Submit