a値確認&編集更新スクリプト

    @@ -1,11 +1,86 @@ /* - * @title テストブックマークレット + * @title a値確認&編集更新スクリプト * @description my bookmarklet * @include https:*.open2ch.net* * @license MIT License * @require */ -alert('テスト表示。次に何か表示されるか?') -alert(document.cookie) +/* +cookieはopen2ch内ではどこでも(hayabusa,uniなど)同じ。 +httpsではなくhttpでなければ使えないので注意。 +http://hayabusa.open2ch.net/livejupiter/ +*/ + +var firstLoadFlag = true + +function IsHanEisu(str){ + str = (str==null)?"":str; + if(str.match(/^[A-Za-z0-9]*$/)){ + return true; + }else{ + return false; + } +} + + + +function getCookie(key) { + // Cookieから値を取得する + var cookieString = document.cookie; + + // 要素ごとに ";" で区切られているので、";" で切り出しを行う + var cookieKeyArray = cookieString.split(";"); + + // 要素分ループを行う + for (var i=0; i<cookieKeyArray.length; i++) { +  var targetCookie = cookieKeyArray[i]; + +  // 前後のスペースをカットする +  targetCookie = targetCookie.replace(/^\s+|\s+$/g, ""); + +  var valueIndex = targetCookie.indexOf("="); +  if (targetCookie.substring(0, valueIndex) == key) { +   // キーが引数と一致した場合、値を返す +   return unescape(targetCookie.slice(valueIndex + 1)); +  } + } + + return ""; +} + + +function aValue_UPD(){ + console.log() + +var aValue = document.getElementById("aValue_txtArea").value +var aValue_checkLen = aValue.length +var aValue_checkWord = IsHanEisu(aValue) +if (aValue_checkLen != 32) {alert('32桁入力してください。\n現在の桁数:'+ aValue_checkLen);return} +if (IsHanEisu(aValue) != true) {alert('半角英数字しか利用できません。');return} +document.cookie= 'a=' + aValue + ';expires=' + new Date('2030/12/31 23:59').toUTCString() +';path=/;domain=open2ch.net'; +alert('書き換え完了。') +} + + +(window.onload = function() { + if (firstLoadFlag == true) { + firstLoadFlag = false + var div_element = document.createElement("div"); + var parent_object + div_element.style.position="fixed" + div_element.style.bottom= 0 + div_element.style.left= 0 + div_element.innerHTML = '' + + div_element.innerHTML = div_element.innerHTML + '<div style="width:500px;"><div style="padding:0px"><div style="padding:0px">' + div_element.innerHTML = div_element.innerHTML + '<input type="text" id="aValue_txtArea" wrap="off" COLS="32" STYLE="resize:none; width:300px; font-size:1em; color:#00FF00; background-color:#404040; overflow:scroll; top:0"></input>' + div_element.innerHTML = div_element.innerHTML + '<div style="width:350px; font-size:1em; color:#FF0000; background-color:#F0F0F0;"">※更新前にコピペなどでバックアップを取ってください<div style="padding:0px"><div style="padding:0px">' + div_element.innerHTML = div_element.innerHTML + '<input type="button" id="aValue_UpdBtn" value="a値更新" style="font-size:20px; WIDTH: 105px; HEIGHT: 45px; LEFT: 0">'; + parent_object = document.getElementsByTagName("body")[0] + parent_object.appendChild(div_element); + document.getElementById("aValue_txtArea").value = getCookie('a') + document.getElementById("aValue_UpdBtn").onclick = function() {aValue_UPD()}; + } +})();
  • /*
     * @title a値確認&編集更新スクリプト
     * @description my bookmarklet
     * @include https:*.open2ch.net*
     * @license MIT License
     * @require 
     */
    
    /*
    cookieはopen2ch内ではどこでも(hayabusa,uniなど)同じ。
    httpsではなくhttpでなければ使えないので注意。
    http://hayabusa.open2ch.net/livejupiter/
    */
    
    var firstLoadFlag = true
    
    function IsHanEisu(str){
      str = (str==null)?"":str;
      if(str.match(/^[A-Za-z0-9]*$/)){
        return true;
      }else{
        return false;
      }
    }
    
    
    
    function getCookie(key) {
     // Cookieから値を取得する
     var cookieString = document.cookie;
    
     // 要素ごとに ";" で区切られているので、";" で切り出しを行う
     var cookieKeyArray = cookieString.split(";");
    
     // 要素分ループを行う
     for (var i=0; i<cookieKeyArray.length; i++) {
      var targetCookie = cookieKeyArray[i];
    
      // 前後のスペースをカットする
      targetCookie = targetCookie.replace(/^\s+|\s+$/g, "");
    
      var valueIndex = targetCookie.indexOf("=");
      if (targetCookie.substring(0, valueIndex) == key) {
       // キーが引数と一致した場合、値を返す
       return unescape(targetCookie.slice(valueIndex + 1));
      }
     }
    
     return "";
    }
    
    
    function aValue_UPD(){
        console.log()
    
    var aValue = document.getElementById("aValue_txtArea").value
    var aValue_checkLen = aValue.length
    var aValue_checkWord = IsHanEisu(aValue)
    if (aValue_checkLen != 32) {alert('32桁入力してください。\n現在の桁数:'+ aValue_checkLen);return}
    if (IsHanEisu(aValue) != true) {alert('半角英数字しか利用できません。');return}
    document.cookie= 'a=' + aValue + ';expires=' + new Date('2030/12/31 23:59').toUTCString() +';path=/;domain=open2ch.net';
    alert('書き換え完了。')
    }
    
    
    (window.onload = function() {
        if (firstLoadFlag == true) {
            firstLoadFlag = false
            var div_element = document.createElement("div");
            var parent_object
            div_element.style.position="fixed"
            div_element.style.bottom= 0
            div_element.style.left= 0
            div_element.innerHTML = ''
    
            div_element.innerHTML = div_element.innerHTML + '<div style="width:500px;"><div style="padding:0px"><div style="padding:0px">'
            div_element.innerHTML = div_element.innerHTML + '<input type="text" id="aValue_txtArea" wrap="off" COLS="32" STYLE="resize:none; width:300px; font-size:1em; color:#00FF00; background-color:#404040; overflow:scroll; top:0"></input>'
            div_element.innerHTML = div_element.innerHTML + '<div style="width:350px; font-size:1em; color:#FF0000; background-color:#F0F0F0;"">※更新前にコピペなどでバックアップを取ってください<div style="padding:0px"><div style="padding:0px">'
            div_element.innerHTML = div_element.innerHTML + '<input type="button" id="aValue_UpdBtn" value="a値更新" style="font-size:20px; WIDTH: 105px; HEIGHT: 45px; LEFT: 0">';
            parent_object = document.getElementsByTagName("body")[0]
            parent_object.appendChild(div_element);
            document.getElementById("aValue_txtArea").value = getCookie('a')
            document.getElementById("aValue_UpdBtn").onclick = function() {aValue_UPD()};
    
        }
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2019/05/03 10:17:30 - 2019-05-03
  2. 2019/05/03 10:11:40 - 2019-05-03
  3. 2019/03/10 16:15:51 - 2019-03-10
  4. 2017/01/22 18:08:06 - 2017-01-22