UTF-8 //ダウンロードマクロ 「mixi CSSアップデータ」 for JTC PROSERPINE (初版: 2008/07/21) // Parameters: // [0] : mixi css URL // [1] : my base URL // [2] : background color // [3] : font color (fore color) // [4] : border color // // 例:『黒mixi』の場合のパラメタ設定 // http://mixi.jp/static/css/basic/header.css // http://milky.geocities.jp/mixi_css/ // #000022 // #FFFFFF // indigo :Main { //log open: dir=Dir.Desktop file="debugMacro.txt"; //debug: true; if (input[0].EndsWith_igC{".css"} == "false") { put: value="!URL Error: 正しいCSSのURLが指定されていません. " input[0]; end: } if (input[0].StartsWith_igC{"http://"} == "false") { put: value="!URL Error: 正しいCSSのURLが指定されていません. " input[0]; end: } Ex:Http-Get: url=input[0] base="mixi.jp" O:text=str["css"]; if (str["css"].Length < 1) { put: value="!Error: URL? " input[0]; end: } str[0]="@charset \"euc-jp\";"; str["css"]=str["css"].Replace(""); str[0]="@charset \"EUC-JP\";"; str["css"]=str["css"].Replace(""); strl["header"]="@charset \"utf-8\";\r\n"; strl["header"]+="/*-- CSS Generated Date: "; strl["header"]+=Time.Now; strl["header"]+=" --*/\r\n"; strl["header"]+="/*-- mixi original css URL: "; strl["header"]+=input[0]; strl["header"]+=" --*/\r\n"; strl["header"]+="/*-- Customize base URL: "; strl["header"]+=input[1]; strl["header"]+=" --*/\r\n"; strl["header"]+="/*-- background color: "; strl["header"]+=input[2]; strl["header"]+=", font color:"; strl["header"]+=input[3]; strl["header"]+=", border color:"; strl["header"]+=input[4]; strl["header"]+=" --*/\r\n\r\n"; intl[10]=input[0].LastIndexOf("/"); culc: intl[10]++; str["cssName"]=input[0].Substring(intl[10]); str["cssName"]+="_src"; put: value="CSS: Creating " str["cssName"] " ...\r\n\r\n"; str[0]="\r"; str["css"]=str["css"].Replace("\n"); str[0]=";"; str["css"]=str["css"].Replace(";\n"); while (str["css"].IndexOf{"\n\n"} >= 0) { str[0]="\n\n"; str["css"]=str["css"].Replace("\n"); } str[0]="\n"; str["css"]=str["css"].Replace("\r\n"); str[0]="\t"; str["css"]=str["css"].Replace(" "); while (str["css"].IndexOf{" "} >= 0) { str[0]=" "; str["css"]=str["css"].Replace(" "); } str[0]="; "; str["css"]=str["css"].Replace(";\r\n"); str[0]=";\t"; str["css"]=str["css"].Replace(";\r\n"); str[0]=";}"; str["css"]=str["css"].Replace(";\r\n}"); //str[0]=" {"; str["css"]=str["css"].Replace("{"); …不要、個別のRegexで対応 // //str[0]=": #"; str["css"]=str["css"].Replace(":#"); str[0]=": "; str["css"]=str["css"].Replace(":"); str[0]=" :"; str["css"]=str["css"].Replace(":"); str["regex"]="([0-9a-zA-Z]+)([ \r\n]+})".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g0"]="gp."; strl["g0"]+=int["c"]; strl["g0"]+=".0"; strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; put: value=strl[strl["g0"]]; str[0]=strl[strl["g0"]]; strl[10]=strl[strl["g1"]]; strl[10]+=";"; strl[10]+=strl[strl["g2"]]; str["css"]=str["css"].Replace(strl[10]); culc: int["c"]++; } put: value=""; if (input[1].StartsWith{"http://"} == "true") { if (input[1].EndsWith{"/"} != "true") { input[1]+="/"; } str[0]="http://img.mixi.jp/img/basic/"; strl[10]=input[1]; strl[10]+="img_basic/"; str["css"]=str["css"].Replace(strl[10]); } str["regex"]="[\r\n \{](border[a-zA-Z\-]*)(:1px solid #.*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; str[0]=strl[strl["g1"]]; str[0]+=strl[strl["g2"]]; put: value=str[0]; str["rpl"]=strl[strl["g1"]]; str["rpl"]+=":1px solid __BORDER_COLOR__;"; str["css"]=str["css"].Replace(str["rpl"]); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](border[a-zA-Z\-]*):([a-zA-Z]+)( 1px #.*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; strl["g3"]="gp."; strl["g3"]+=int["c"]; strl["g3"]+=".3"; str[0]=strl[strl["g1"]]; str[0]+=":"; str[0]+=strl[strl["g2"]]; // "solid" -or- "dotted" str[0]+=strl[strl["g3"]]; // " 1px #123456:" put: value=str[0]; str["rpl"]=strl[strl["g1"]]; str["rpl"]+=":1px "; str["rpl"]+=strl[strl["g2"]]; str["rpl"]+=" __BORDER_COLOR__;"; str["css"]=str["css"].Replace(str["rpl"]); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](border-[a-zA-Z]*)(:1px #.*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; str[0]=strl[strl["g1"]]; str[0]+=strl[strl["g2"]]; put: value=str[0]; str["rpl"]=strl[strl["g1"]]; str["rpl"]+=":1px __BORDER_COLOR__;"; str["css"]=str["css"].Replace(str["rpl"]); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](border:1px #.*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; str[0]=strl[strl["g1"]]; put: value=str[0]; str["rpl"]="border:1px __BORDER_COLOR__;"; str["css"]=str["css"].Replace(str["rpl"]); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](border-color:)([#0-9a-zA-Z]+)([;\}])".surrogate; // // for "border-color:#D6D6D6;" // for "border-color:black;" // Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; strl["g3"]="gp."; strl["g3"]+=int["c"]; strl["g3"]+=".3"; //put: value="Found: " strl[strl["g1"]]; str[0]=strl[strl["g1"]]; str[0]+=strl[strl["g2"]]; str[0]+=strl[strl["g3"]]; str["rpl"]="border-color:__BORDER_COLOR__"; str["rpl"]+=strl[strl["g3"]]; str["css"]=str["css"].Replace(str["rpl"]); put: value="Replaced: " str[0] " → " str["rpl"]; culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](border-color:)([#0-9a-zA-Z]+)( rgb.*)([;\}])".surrogate; // // for "border-color:#D6D6D6 rgb(214, 214, 214);" // for "border-color:black rgb(214, 214, 214);" // Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; strl["g3"]="gp."; strl["g3"]+=int["c"]; strl["g3"]+=".3"; strl["g4"]="gp."; strl["g4"]+=int["c"]; strl["g4"]+=".4"; str[0]=strl[strl["g1"]]; str[0]+=strl[strl["g2"]]; str[0]+=strl[strl["g3"]]; str[0]+=strl[strl["g4"]]; str["rpl"]="border-color:__BORDER_COLOR__"; str["rpl"]+=strl[strl["g4"]]; str["css"]=str["css"].Replace(str["rpl"]); put: value="Replaced: " str[0] " → " str["rpl"]; culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background:[#0-9a-zA-Z]+[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp"]="gp."; strl["gp"]+=int["c"]; strl["gp"]+=".1"; put: value=strl["gp"] " = " strl[strl["gp"]]; str[0]=strl[strl["gp"]]; str["css"]=str["css"].Replace("/*-- background:__BACKGROUND_COLOR__; --*/"); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background:[#0-9a-zA-Z]* \!importa.*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp"]="gp."; strl["gp"]+=int["c"]; strl["gp"]+=".1"; put: value=strl["gp"] " = " strl[strl["gp"]]; str[0]=strl[strl["gp"]]; str["css"]=str["css"].Replace("/*-- background:__BACKGROUND_COLOR__; --*/"); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background:[#0-9a-zA-Z]* url\()".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp"]="gp."; strl["gp"]+=int["c"]; strl["gp"]+=".1"; put: value=strl["gp"] " = " strl[strl["gp"]]; str[0]=strl[strl["gp"]]; str["css"]=str["css"].Replace("/*-- bg:__BACKGROUND_COLOR__ --*/\r\nbackground:url("); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background:url\(.*)( #[0-9a-zA-Z]+[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["g0"]="gp."; strl["g0"]+=int["c"]; strl["g0"]+=".0"; strl["g1"]="gp."; strl["g1"]+=int["c"]; strl["g1"]+=".1"; strl["g2"]="gp."; strl["g2"]+=int["c"]; strl["g2"]+=".2"; strl[10]=strl[strl["g1"]]; strl[10]+=strl[strl["g2"]]; put: value=strl[10]; str[0]=strl[10]; strl[11]=strl[strl["g1"]]; strl[11]+="; /*-- bg:__BACKGROUND_COLOR__ --*/"; str["css"]=str["css"].Replace(strl[11]); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background-color:[#0-9a-zA-Z]+[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp"]="gp."; strl["gp"]+=int["c"]; strl["gp"]+=".1"; put: value=strl["gp"] " = " strl[strl["gp"]]; str[0]=strl[strl["gp"]]; str["css"]=str["css"].Replace("/*-- background:__BACKGROUND_COLOR__; --*/"); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background-color:[#0-9a-zA-Z]+ .*[;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp"]="gp."; strl["gp"]+=int["c"]; strl["gp"]+=".1"; put: value=strl["gp"] " = " strl[strl["gp"]]; str[0]=strl[strl["gp"]]; str["css"]=str["css"].Replace("/*-- background:__BACKGROUND_COLOR__; --*/"); culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](background-color:rgb\([0-9, ]+\))([;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp1"]="gp."; strl["gp1"]+=int["c"]; strl["gp1"]+=".1"; strl["gp2"]="gp."; strl["gp2"]+=int["c"]; strl["gp2"]+=".2"; put: value=strl["gp1"] "=" strl[strl["gp1"]] ", " strl["gp2"] "=" strl[strl["gp2"]]; if (strl[strl["gp2"]] == ";") { str[0]=strl[strl["gp1"]]; str[0]+=";"; str["css"]=str["css"].Replace("/*-- background-color:__FONT_COLOR__; --*/"); } else { str[0]=strl[strl["gp1"]]; str[0]+="}"; str["css"]=str["css"].Replace("/*-- background-color:__FONT_COLOR__; --*/\r\n}"); } culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](color:[#0-9a-zA-Z]+)([;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp1"]="gp."; strl["gp1"]+=int["c"]; strl["gp1"]+=".1"; strl["gp2"]="gp."; strl["gp2"]+=int["c"]; strl["gp2"]+=".2"; put: value=strl["gp1"] "=" strl[strl["gp1"]] ", " strl["gp2"] "=" strl[strl["gp2"]]; if (strl[strl["gp2"]] == ";") { str[0]=strl[strl["gp1"]]; str[0]+=";"; str["css"]=str["css"].Replace("/*-- color:__FONT_COLOR__; --*/"); } else { str[0]=strl[strl["gp1"]]; str[0]+="}"; str["css"]=str["css"].Replace("/*-- color:__FONT_COLOR__; --*/\r\n}"); } culc: int["c"]++; } put: value=""; str["regex"]="[\r\n \{](color:rgb\([0-9, ]+\))([;\}])".surrogate; Regex: src=str["css"] regex=str["regex"] O:count=int["count"] strl.prefix="gp"; put: value=str["regex"] ", count=" int["count"]; int["c"]=0; while (int["c"] < int["count"]) { strl["gp1"]="gp."; strl["gp1"]+=int["c"]; strl["gp1"]+=".1"; strl["gp2"]="gp."; strl["gp2"]+=int["c"]; strl["gp2"]+=".2"; put: value=strl["gp1"] "=" strl[strl["gp1"]] ", " strl["gp2"] "=" strl[strl["gp2"]]; if (strl[strl["gp2"]] == ";") { str[0]=strl[strl["gp1"]]; str[0]+=";"; str["css"]=str["css"].Replace("/*-- color:__FONT_COLOR__; --*/"); } else { str[0]=strl[strl["gp1"]]; str[0]+="}"; str["css"]=str["css"].Replace("/*-- color:__FONT_COLOR__; --*/\r\n}"); } culc: int["c"]++; } put: value=""; if (input[2].Length >= 3) { //"red"が最短か? put: value="背景色: " input[2]; str[0]="__BACKGROUND_COLOR__"; str["css"]=str["css"].Replace(input[2]); } if (input[3].Length >= 3) { //"red"が最短か? put: value="文字色: " input[3]; str[0]="__FONT_COLOR__"; str["css"]=str["css"].Replace(input[3]); } if (input[4].Length >= 3) { //"red"が最短か? put: value="枠色: " input[4]; str[0]="__BORDER_COLOR__"; str["css"]=str["css"].Replace(input[4]); } strl["header"]+=str["css"]; str["css"]=strl["header"]; write open: dir=Dir.Desktop file=str["cssName"]; write0: str["css"]; write close: }