GETパラメータ整形表示

  • /*
     * @title GETパラメータ整形表示
     * @description GETパラメータを整形して表示します。パラメータを変更してリロードも可能です。
     * @include http://*
     * @license MIT License
     * @require jquery
     *
     * 2010/12/07 表示方法変更(TSVやめました)
     */
    
    (function () {
    
    var nm = 'jp_hatelabo_let_equinox79_';
    var id = {
      'panel' : nm + 'panel',
      'url'   : nm + 'url',
      'param' : nm + 'param'
    };
    var delimiter = "=";
    
    var elm = location.href.split('?');
    var str = "";
    if(elm.length > 1){
      var params = elm[1].split('&');
      for(var i=0; i<params.length; i++){
        str += params[i].replace(/=/, delimiter);
        str += "\r\n";
      }
    }
    
    if( $('#'+id['panel']).length > 0 ) $('#'+id['panel']).remove();
    
    var createGetParamFromTSV = function(tsv){
      var params = tsv.replace(/\n{2,}/g, '\n').replace(/\n$/, '').replace(/=/g,"=").replace(/\n/g,"&");
      return params;  
    };
    
    $('body').prepend(
     $('<div id=' + id['panel'] + ' style="margin:5px;padding:5px;position:absolute;widh:50%;border:1px solid gray;z-index:99999;background-color:white;">').css('top', $(window).scrollTop()).append(
      $('<b>GETパラメータを分解</b><br>')
     ).append(
      $('<input>').attr({id : id['url'], 'value' : elm[0]}).css({'width':'99%', 'margin':'1px'})
     ).append(
      $('<br>')
     ).append(
      $('<textarea>').attr({id : id['param'], 'cols':76,'rows':10}).text(str)
     ).append(
      $('<br><input type="button" value="close">').click(function(){
       $('#'+id['panel']).remove()
      })
     ).append(
      $('<input type="button" value="上記のパラメータでリロード">').click(function(){
        var url = elm[0] + '?' + createGetParamFromTSV( $('#'+id['param']).val() );
        location.href = url;
      })
     )
    );
    
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/12/07 18:19:13 - 2010-12-07
  2. 2010/12/07 18:11:56 - 2010-12-07
  3. 2010/12/07 18:08:04 - 2010-12-07
  4. 2010/12/06 14:51:51 - 2010-12-06
  5. 2010/12/06 14:39:23 - 2010-12-06
  6. 2010/12/01 17:01:12 - 2010-12-01
  7. 2010/12/01 16:55:39 - 2010-12-01
  8. 2010/12/01 16:21:59 - 2010-12-01
  9. 2010/12/01 16:19:03 - 2010-12-01