<commit_before>const { remote, webFrame } = require('electron')
const config = remote.require('./lib/config')

window.ipc = remote.require('./lib/ipc')

if (config.get('poi.content.muted', false)) {
  remote.getCurrentWebContents().setAudioMuted(true)
}

document.addEventListener('DOMContentLoaded', (e) => {
  if (config.get('poi.misc.dmmcookie', false)) {
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/"
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/"
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=osapi.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=172.16.31.10;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=www.dmm.com;path=/netgame/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=log-netgame.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/"
    const ua = remote.getCurrentWebContents().session.getUserAgent()
    remote.getCurrentWebContents().session.setUserAgent(ua, 'ja-JP')
  }
  if (config.get('poi.misc.disablenetworkalert', false) && window.DMM) {
    window.DMM.netgame.reloadDialog=function(){}
  }
})

// Faster align setting
const alertCSS =
`#alert {
  left: 270px !important;
  top: 83px !important;
  border: 0;
}
`

const alignCSS = document.createElement('style')
alignCSS.innerHTML =
`html {
  overflow: hidden;
}
#w, #main-ntg {
  position: absolute !important;
  top: 0;
  left: 0;
  z-index: 100;
  margin-left: 0 !important;
  margin-top: 0 !important;
}
#game_frame {
  width: 1200px !important;
  position: absolute;
  top: 0px;
  left: 0;
}
.naviapp {
  z-index: -1;
}
#ntg-recommend {
  display: none !important;
}
`

function handleSpacingTop(show) {
  const status = show ? 'block' : 'none'
  if (document.querySelector('#spacing_top')) {
    document.querySelector('#spacing_top').style.display = status
  }
  if (!document.querySelector('#game_frame')) {
    return
  }
  function t(count) {
    try {
      if (count > 20) {
        return
      }
      document.querySelector('#game_frame').contentWindow.document.querySelector('#spacing_top').style.display = status
    } catch (e) {
      setTimeout(() => t(count + 1), 1000)
    }
  }
  t(0)
}

window.align = function () {
  document.body.appendChild(alignCSS)
  handleSpacingTop(false)
  window.scrollTo(0, 0)
  window.ipc.access('WebView').getWebviewWidth(width => {
    const zoom = Math.round(width * config.get('poi.appearance.zoom', 1)) / 1200
    webFrame.setZoomFactor(zoom)
    const zl = webFrame.getZoomLevel()
    webFrame.setLayoutZoomLevelLimits(zl, zl)
  })
}

window.unalign = () => {
  document.body.removeChild(alignCSS)
  if (document.querySelector('#spacing_top')) {
    document.querySelector('#spacing_top').style.display = 'block'
  }<commit_msg>fix: wrong zoomfactor of webview<commit_after>const { remote, webFrame } = require('electron')
const config = remote.require('./lib/config')

window.ipc = remote.require('./lib/ipc')

if (config.get('poi.content.muted', false)) {
  remote.getCurrentWebContents().setAudioMuted(true)
}

document.addEventListener('DOMContentLoaded', (e) => {
  if (config.get('poi.misc.dmmcookie', false)) {
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/"
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/"
    document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=osapi.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=172.16.31.10;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=www.dmm.com;path=/netgame/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=log-netgame.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/"
    document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/"
    const ua = remote.getCurrentWebContents().session.getUserAgent()
    remote.getCurrentWebContents().session.setUserAgent(ua, 'ja-JP')
  }
  if (config.get('poi.misc.disablenetworkalert', false) && window.DMM) {
    window.DMM.netgame.reloadDialog=function(){}
  }
})

// Faster align setting
const alertCSS =
`#alert {
  left: 270px !important;
  top: 83px !important;
  border: 0;
}
`

const alignCSS = document.createElement('style')
alignCSS.innerHTML =
`html {
  overflow: hidden;
}
#w, #main-ntg {
  position: absolute !important;
  top: 0;
  left: 0;
  z-index: 100;
  margin-left: 0 !important;
  margin-top: 0 !important;
}
#game_frame {
  width: 1200px !important;
  position: absolute;
  top: 0px;
  left: 0;
}
.naviapp {
  z-index: -1;
}
#ntg-recommend {
  display: none !important;
}
`

function handleSpacingTop(show) {
  const status = show ? 'block' : 'none'
  if (document.querySelector('#spacing_top')) {
    document.querySelector('#spacing_top').style.display = status
  }
  if (!document.querySelector('#game_frame')) {
    return
  }
  function t(count) {
    try {
      if (count > 20) {
        return
      }
      document.querySelector('#game_frame').contentWindow.document.querySelector('#spacing_top').style.display = status
    } catch (e) {
      setTimeout(() => t(count + 1), 1000)
    }
  }
  t(0)
}

window.align = function () {
  document.body.appendChild(alignCSS)
  handleSpacingTop(false)
  window.scrollTo(0, 0)
  window.ipc.access('WebView').getWebviewWidth(width => {
    const zoom = Math.round(width * config.get('poi.appearance.zoom', 1)) / 1200
    if (Number.isNaN(zoom)) {
      setTimeout(window.align, 1000)
      return
    }
    webFrame.setZoomFactor(zoom)
    const zl = webFrame.getZoomLevel()
    webFrame.setLayoutZoomLevelLimits(zl, zl)
  })
}

window.unalign = () => {
  document.body.removeChild(alignCSS)
  if (document.querySelector('#spacing_top')) {
    document.querySelector('#spacing_top').style.display = 'block'
  }
{'fraction_non_alphanumeric': 0.16453985888004805, 'fraction_numerical': 0.051944152529650206, 'mean_word_length': 4.221003134796239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1526012', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2399, 'n_words': 425}