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

    @@ -1,38 +1,90 @@ -//"document" requires the url which ends with ".dat" extension in the domain of "open2ch.net" -//Use this code only under JavaScript Console!!(i recommend Google Chrome because i only use it with test) -var d = document.getElementsByTagName("pre")[0].textContent; -var ds = d.split("\n"); - -var koteAll = ds.map(function(elm){ return elm.split("<>")[0]} ) -.filter(function(elm){ return (/.+◆/).test(elm)} ) -.map(function(elm){ return elm.replace(/<.?b>/g,"").replace(">",">","g").replace(/忍法帖【.*】/g,"")} ) -.sort(); - -var koteUniq = koteAll.filter(function (x, i, self) { return self.indexOf(x) === i;}); - - -var res = koteUniq.map( -function(elmU){ -return (koteAll.filter(function(elmA){ -return elmA == elmU;})); +/* + * @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 + +/* +こっから丸ごとコピペしてきました。 +https://javascript.programmer-reference.com/js-check-hankaku-eisu/ +*/ +function IsHanEisu(str){ + str = (str==null)?"":str; + if(str.match(/^[A-Za-z0-9]*$/)){ + return true; + }else{ + return false; + } } -); -var sorted = res.sort(function(a,b){ -return b.length - a.length ; -}); +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)); +  } + } -var output_names = sorted.map(function(elm){return elm[0]}); -var output_values = sorted.map(function(elm){return elm.length}); + return ""; +} -var output = [];//output[0]←コテハンの名前, output[1]←各コテハンのレス数 -output.push(output_names); -output.push(output_values); +function aValue_UPD(){ + console.log() -//結果書き込み -for(var i = 0; i < output[0].length; i++){ -document.write(output[0][i] + "," + output[1][i] + "<br>"); +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('半error:1<br>半角英数字しか使えないんやで');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
    
    /*
    こっから丸ごとコピペしてきました。
    https://javascript.programmer-reference.com/js-check-hankaku-eisu/
    */
    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('半error:1<br>半角英数字しか使えないんやで');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. 2021/03/08 16:08:06 - 2021-03-08
  2. 2021/03/08 16:05:45 - 2021-03-08
  3. 2021/03/08 16:03:43 - 2021-03-08
  4. 2021/03/08 16:01:59 - 2021-03-08
  5. 2021/03/08 14:49:46 - 2021-03-08
  6. 2021/03/08 14:24:38 - 2021-03-08
  7. 2021/03/08 14:22:30 - 2021-03-08
  8. 2021/03/08 14:20:06 - 2021-03-08
  9. 2021/03/08 14:01:27 - 2021-03-08
  10. 2021/03/08 13:59:47 - 2021-03-08
  11. 2021/03/08 13:49:29 - 2021-03-08
  12. 2021/03/08 13:46:28 - 2021-03-08
  13. 2021/03/08 13:43:44 - 2021-03-08
  14. 2021/03/08 13:36:12 - 2021-03-08
  15. 2021/03/08 13:33:05 - 2021-03-08
  16. 2021/03/08 13:30:17 - 2021-03-08
  17. 2021/03/08 13:26:38 - 2021-03-08
  18. 2021/03/08 13:23:13 - 2021-03-08
  19. 2021/03/08 13:18:45 - 2021-03-08
  20. 2021/03/08 13:17:37 - 2021-03-08
  21. 2021/03/08 13:06:10 - 2021-03-08
  22. 2021/03/08 13:03:33 - 2021-03-08
  23. 2021/03/08 12:55:12 - 2021-03-08