<commit_before>class ExciteBlogWriter
  attr_reader :browser, :wait

  def initialize
    @browser = Selenium::WebDriver.for :firefox
    @wait = Selenium::WebDriver::Wait.new(:timeout => 15)
  end

  def login
    info 'Logging in...'
    browser.get "http://www.excite.co.jp/?pname=blog&brand=xcit&lin=1&targeturl=http%3A%2F%2Fwww.exblog.jp%2F"

    input = wait.until {
      element = browser.find_element(:name, "acctname")
      element if element.displayed?
    }
    input.send_keys(Settings.excite.id)

    input = wait.until {
      element = browser.find_element(:name, "passwd")
      element if element.displayed?
    }
    input.send_keys(Settings.excite.pass)

    form = wait.until {
      element = browser.find_element(:name, "login_form")
      element if element.displayed?
    }

    form.find_element(:name, "_action").click
    sleep 4

    info "Logged in."
  end

  def edit_content(excite_id, content)
    info "Editing #{excite_id}..."
    browser.get edit_url(excite_id)
    sleep 4 # 日付のselect boxが選択されるのを待つ

    input = wait.until {
      element = browser.find_element(:name, "content")
      element if element.displayed?
    }
    old_content = input.text
    input.clear
    input.send_keys content

    more_content = clear_more(excite_id, submit: false)

    submit_edit_form

    old_content += "\n\n#{more_content}" if more_content.present?

    old_content
  end

  def clear_more(excite_id, submit: false)
    info "Clear more for #{excite_id}"

    browser.get edit_url(excite_id)
    sleep 4 # 日付のselect boxが選択されるのを待つ

    checkbox = wait.until {
      element = browser.find_element(:name, "moreflag")
      element if element.displayed?
    }

    if checkbox.selected?
      input = wait.until {
        element = browser.find_element(:name, "morecontent")
        element if element.displayed?
      }
      old_content = input.text
      input.clear
<commit_msg>Fix bug.<commit_after>class ExciteBlogWriter
  attr_reader :browser, :wait

  def initialize
    @browser = Selenium::WebDriver.for :firefox
    @wait = Selenium::WebDriver::Wait.new(:timeout => 15)
  end

  def login
    info 'Logging in...'
    browser.get "http://www.excite.co.jp/?pname=blog&brand=xcit&lin=1&targeturl=http%3A%2F%2Fwww.exblog.jp%2F"

    input = wait.until {
      element = browser.find_element(:name, "acctname")
      element if element.displayed?
    }
    input.send_keys(Settings.excite.id)

    input = wait.until {
      element = browser.find_element(:name, "passwd")
      element if element.displayed?
    }
    input.send_keys(Settings.excite.pass)

    form = wait.until {
      element = browser.find_element(:name, "login_form")
      element if element.displayed?
    }

    form.find_element(:name, "_action").click
    sleep 4

    info "Logged in."
  end

  def edit_content(excite_id, content)
    info "Editing #{excite_id}..."
    browser.get edit_url(excite_id)
    sleep 4 # 日付のselect boxが選択されるのを待つ

    input = wait.until {
      element = browser.find_element(:name, "content")
      element if element.displayed?
    }
    old_content = input.text
    input.clear
    input.send_keys content

    more_content = clear_more(excite_id, submit: false, open_page: false)

    submit_edit_form

    old_content += "\n\n#{more_content}" if more_content.present?

    old_content
  end

  def clear_more(excite_id, submit: false, open_page: true)
    info "Clear more for #{excite_id}"

    if open_page
      browser.get edit_url(excite_id)
      sleep 4 # 日付のselect boxが選択されるのを待つ
    end

    checkbox = wait.until {
      element = browser.find_element(:name, "moreflag")
      element if element.displayed?
    }

    if checkbox.selected?
      input = wait.until {
        element = browser.find_element(:name, "morecontent")
        element if element.displayed?
      }
      old_content = input.text
      input.clear

{'fraction_non_alphanumeric': 0.1101367036368326, 'fraction_numerical': 0.005158627805003869, 'mean_word_length': 2.94908350305499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, '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': '499446', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1300, 'n_words': 262}