twitter_draft

    @@ -1,22 +1,37 @@ -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'>"); -var result2 = document.evaluate('//input', document, null, 7, null); -result2.snapshotItem(0).addEventListener('click', sample, false); -result2.snapshotItem(1).addEventListener('click', sample2, false); +// ==UserScript== +// @title twitter_draft +// @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 +// ==/UserScript== +var result = document.evaluate('id("global-new-tweet-button")', document, null, 7, null); +result.snapshotItem(0).insertAdjacentHTML('afterend', '<input type="checkbox" id="draft">'); +document.getElementById("draft").addEventListener('change', function () { + if (document.getElementById("draft").checked) { + 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'>"); + 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 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; -} -window.addEventListener('popstate', function (event) { - location.href = localStorage.getItem("n_url"); - //history.back(); + function sample2() { + var result3 = document.evaluate('//textarea', document, null, 7, null); + var draft = localStorage.getItem('draft'); + result3.snapshotItem(0).value = draft; + } + window.addEventListener('popstate', function (event) { + location.href = localStorage.getItem("n_url"); + }); + } });
  • // ==UserScript==
    // @title        twitter_draft
    // @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
    // ==/UserScript==
    var result = document.evaluate('id("global-new-tweet-button")', document, null, 7, null);
    result.snapshotItem(0).insertAdjacentHTML('afterend', '<input type="checkbox" id="draft">');
    document.getElementById("draft").addEventListener('change', function () {
      if (document.getElementById("draft").checked) {
        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'>");
        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;
        }
        window.addEventListener('popstate', function (event) {
          location.href = localStorage.getItem("n_url");
        });
      }
    });
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/11/18 12:57:07 - 2018-11-18
  2. 2018/11/17 21:38:02 - 2018-11-17
  3. 2018/11/17 21:22:53 - 2018-11-17
  4. 2018/11/12 11:11:56 - 2018-11-12
  5. 2018/11/08 09:57:41 - 2018-11-08