no title [bookmarklet]

    @@ -55,6 +55,11 @@ return ''; }; + p.isnull= function(obj,val) { + if(!obj){return val;} + return obj + }; + //return object return td_util; })(); @@ -111,6 +116,11 @@ } } console.log(breads); +console.log(tdu.isnull(breads[0],"")); +console.log(tdu.isnull(breads[1],"")); +console.log(tdu.isnull(breads[2],"")); +console.log(tdu.isnull(breads[3],"")); + //第一パス var path_array = location.pathname.split('/');
  • var td_util = (function() {
    
        // constructor
        var td_util = function(arg) {};
        var p = td_util.prototype;
    
        //arias get element id
        p.id = function(key) {
          return document.getElementById(key);
        };
    
        //arias get elements tags
        p.tag = function(key) {
          return document.getElementsByTagName(key);
        };
    
        //arias get elements class
        p.class = function(key) {
          return document.getElementsByClassName(key);
        };
    
        //arias get elements selecter
        p.selector = function(key) {
          return document.querySelector(key);
        };
    
        //arias get elements selecter
        p.selectorAll = function(key) {
          return document.querySelectorAll(key);
        };
    
        //get url parameter value
        p.getUrlPatam = function(key) {
          var regexp = new RegExp('' + key + '=(.*?)(&|$)');
          var found = location.search.match(regexp);
          if (found) {
            return decodeURIComponent(found[1]);
          }
          return '';
        };
    
        //get cookie parameter value
        p.getCookie = function(key) {
          var result = [];
          var cookies = document.cookie;
          if (cookies != '') {
            var cookieArray = cookies.split(';');
            for (var i = 0; i < cookieArray.length; i++) {
              var cookie = cookieArray[i].split('=');
              if (cookie[0] == key) {
                return decodeURIComponent(cookie[1]);
              }
            }
          }
          return '';
        };
    
        p.isnull= function(obj,val) {
          if(!obj){return val;}
          return obj
        };
    
        //return object
        return td_util;
    })();
    
    var tdu = new td_util();
    
    //生産終了 Start
    var url = location.href;
    if(url.indexOf("p-db")>=0){
      var obj = tdu.class('addstate');
      if(obj){
        for(var i = 0; i < obj.length; ++i){
          if(obj[i].innerHTML.replace(/[\n\r]/g,"") == "生産終了"){
            console.log("生産終了");
            break;
          }
        }
      }
    }
    //生産終了 End
    
    
    //品番
    var url = location.href;
    if(url.indexOf("p-db")>=0){
      var id = url.replace(".html","").substr(url.indexOf("/p-db/")+6).split("_")[0];
      if(id.indexOf("/") == -1 && id.indexOf("?") == -1 && id.indexOf("&") ==  -1 && id.indexOf("=") == -1){
        console.log(id);
      }
    }
    
    //パンくず
    var url = location.href;
    var breads = [];
    if(url.indexOf("p-db")>=0){
      //PRIDE
      var breads = tdu.selector('#sectionContents > div.ga2012_breadcrumbs > p').innerText.replace(/\s+/g, '').replace('個人向けトップ>', '').split(">");
    
    }else{
      //WCS
      var pre_breads;
      pre_breads = tdu.selectorAll('#localheader > div > div.breadcrumbs-element > div > div > nav > ol > li');
    
      if(pre_breads.length==0){
          var breads = tdu.selector('#sectionContents > div.ga2012_breadcrumbs > p').innerText.replace(/\s+/g, '').replace('個人向けトップ>', '').split(">");
      }
    
      if(pre_breads.length!=0){
        for(var i = 0; i < pre_breads.length; ++i){
          if(pre_breads[i].innerText != "" && pre_breads[i].innerText != "個人向けトップ"){
            breads.push(pre_breads[i].innerText);
          }
        }
      }
    }
    console.log(breads);
    console.log(tdu.isnull(breads[0],""));
    console.log(tdu.isnull(breads[1],""));
    console.log(tdu.isnull(breads[2],""));
    console.log(tdu.isnull(breads[3],""));
    
    
    //第一パス
    var path_array = location.pathname.split('/');
    if(path_array.length!=0){
      for(var i = 0; i < path_array.length; ++i){
        if(path_array[i] != "" && path_array[i].indexOf(".")==-1){
          console.log(path_array[i]);
          break;
        }
      }
    }
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2017/10/06 21:42:37 - 2017-10-06
  2. 2017/10/06 19:53:49 - 2017-10-06
  3. 2017/10/06 19:53:08 - 2017-10-06
  4. 2017/10/06 19:47:12 - 2017-10-06
  5. 2017/10/06 19:45:50 - 2017-10-06
  6. 2017/10/06 19:44:53 - 2017-10-06
  7. 2017/10/06 19:42:21 - 2017-10-06
  8. 2017/10/06 19:29:30 - 2017-10-06
  9. 2017/10/06 19:26:56 - 2017-10-06
  10. 2017/10/06 19:26:22 - 2017-10-06
  11. 2017/10/06 19:25:30 - 2017-10-06
  12. 2017/10/06 19:24:15 - 2017-10-06
  13. 2017/10/06 17:48:24 - 2017-10-06
  14. 2017/10/06 17:17:01 - 2017-10-06
  15. 2017/10/06 16:32:59 - 2017-10-06
  16. 2017/10/06 16:24:06 - 2017-10-06
  17. 2017/10/06 16:20:09 - 2017-10-06
  18. 2017/10/06 16:03:28 - 2017-10-06
  19. 2017/10/06 16:02:39 - 2017-10-06
  20. 2017/10/06 15:29:26 - 2017-10-06
  21. 2017/10/06 15:24:29 - 2017-10-06
  22. 2017/10/06 15:21:00 - 2017-10-06
  23. 2017/10/06 15:14:44 - 2017-10-06
  24. 2017/10/06 15:12:00 - 2017-10-06
  25. 2017/10/06 15:09:45 - 2017-10-06
  26. 2017/10/06 15:08:28 - 2017-10-06
  27. 2017/10/06 14:33:43 - 2017-10-06
  28. 2017/10/06 14:29:27 - 2017-10-06
  29. 2017/10/06 14:27:50 - 2017-10-06
  30. 2017/10/06 14:13:02 - 2017-10-06
  31. 2017/10/06 14:05:14 - 2017-10-06
  32. 2017/10/06 14:05:03 - 2017-10-06
  33. 2017/10/06 14:03:31 - 2017-10-06