1300

移行用のテストです

Twitterで下書きを保存

このスクリプトFirefoxで動作を保証しないものとします
http://let.hatelabo.jp/jigendaddy/let/hJmd3o2Zm8Q7.js

// ==UserScript==
// @name         twitter_draft
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://twitter.com/*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
// ==/UserScript==
var result = document.evaluate('id("global-new-tweet-button")', document, null, 7, null);
result.snapshotItem(0).insertAdjacentHTML('afterend', '<input type="button" id="draft" value="下書き">');
document.getElementById("draft").addEventListener('click', function () {
  localStorage.setItem("n_url", location.href);
  history.pushState(null, null, "/koko_nanimo_naidesuyo");
  document.body.innerHTML = "";
  document.body.insertAdjacentHTML("beforeend", "<textarea>戻るボタンなどのブラウザバックで元のページに戻ります</textarea><br><input type='button' value='save'><input type='button' value='load'><span class='count'>0</span>");
  var result2 = document.evaluate('//input', document, null, 7, null);
  result2.snapshotItem(0).addEventListener('click', sample, false);
  result2.snapshotItem(1).addEventListener('click', sample2, false);

  function sample() {
    var result3 = document.evaluate('//textarea', document, null, 7, null);
    localStorage.setItem('draft', result3.snapshotItem(0).value);
  }

  function sample2() {
    var result3 = document.evaluate('//textarea', document, null, 7, null);
    var draft = localStorage.getItem('draft');
    result3.snapshotItem(0).value = draft;
  }
  $('textarea').bind('keydown keyup keypress change', function () {
    var thisValueLength = $(this).val().length;
    $('.count').html(thisValueLength + "/140");
  });
  window.addEventListener('popstate', function (event) {
    location.href = localStorage.getItem("n_url");
  });
});