Sleazy Fork is available in English.

oshioki notifecation

おしおき支援ソフト第1弾 発展場情報の板が自動更新します。 ついでに音でお知らせします。

  1. // ==UserScript==
  2. // @name oshioki notifecation
  3. // @namespace QuinceProject
  4. // @description おしおき支援ソフト第1弾 発展場情報の板が自動更新します。 ついでに音でお知らせします。
  5. // @include http://77.xmbs.jp/miyuki-*-br_res.php?*
  6. // @exclude *disp=*
  7. // @version 1.02
  8. // @grant none
  9. // ==/UserScript==
  10. //
  11. // 対象ウェブブラウザは以下の通りです
  12. // Firefox : 3.5以降(HTML5.1対応ブラウザ)
  13. // (Chromeについては現在確認できていません)
  14. //
  15.  
  16. (function(){
  17.  
  18. //設定 (☆星がついたものは変更可能です)
  19. //設定はCookieによる保護をしています。
  20. var Cookies_Recipe ={
  21. // ☆ cookieの保管日数 ☆
  22. hokanbi : 14,
  23. // ☆ お知らせ音のURL/pass ☆
  24. load_Music : "https://dl.dropbox.com/u/7079101/coin.mp3",
  25. // ☆ お知らせ音のボリューム(0-100の範囲) ☆
  26. volume_Music : 60,
  27. // ☆ リロード時間 (サーバー保護のため60秒以上にしてください) ☆
  28. reload_Time : 60,
  29. //対象の掲示板のURL
  30. load_URL : "",
  31. //最後にリロードした時のレス番号
  32. Res_Last : 1,
  33. //最後にチェックした時のレス番号( Res_Last >= Res_Checked )
  34. Res_Checked : 1,
  35. };
  36. //最新レス番号の取得用関数
  37. function load_ResNo(){
  38. var myNumber;
  39. var myNodes = document.getElementsByTagName('font');
  40. myString = new String();
  41. myString = myNodes[9].firstChild.nodeValue;
  42. //9番目のfont直下が最新レスの番号に当たる
  43. if(!myString){
  44. myNumber = 0;
  45. //fontの最初の子ノードが文字列でなければ0を返す
  46. }
  47. else{
  48. myString = myString.replace( /\D/ , '' ); //数字以外を消す
  49. myNumber = parseInt(myString,10);
  50. if(!myNumber){
  51. myNumber = -1;
  52. //TEXTの形式が"No.XXXX"でなければ-1を返す
  53. }
  54. }
  55. return myNumber;
  56. }
  57. //Cookieの書き込み用関数
  58. function makeCookie(MyCookies_Recipe){
  59. var expire = new Date();
  60. expire.setTime( expire.getTime() + MyCookies_Recipe.hokanbi * 1000 * 3600 * 24 );
  61. document.cookie = 'load_URL='+ MyCookies_Recipe.load_URL + '; expires=' + expire.toUTCString();
  62. document.cookie = 'Res_Last='+ MyCookies_Recipe.Res_Last + '; expires=' + expire.toUTCString();
  63. document.cookie = 'Res_Checked='+ MyCookies_Recipe.Res_Checked + '; expires=' + expire.toUTCString();
  64. document.cookie = 'load_Music='+ MyCookies_Recipe.load_Music + '; expires=' + expire.toUTCString();
  65. document.cookie = 'volume_Music='+ MyCookies_Recipe.volume_Music + '; expires=' + expire.toUTCString();
  66. document.cookie = 'reload_Time='+ MyCookies_Recipe.reload_Time + '; expires=' + expire.toUTCString();
  67. return 0;
  68. }
  69. //Cookieの読み取り用関数
  70. function eatCookie(MyCookies_Recipe){
  71. var allcookies = document.cookie;
  72. if( allcookies != ''){
  73. var cookies = allcookies.split( ';' );
  74. for(var i = 0;i < cookies.length; i++){
  75. cookies[i] = cookies[i].replace( /=/ , ';' ); //最初の'='のみ置き換え
  76. cookies[i] = cookies[i].replace( / /gi , '' ); //空白は消す
  77. var cookie = cookies[i].split( ';' ); //もとが'='の部分で分割
  78. if(cookie[0] == "load_URL"){
  79. MyCookies_Recipe.load_URL = cookie[1];
  80. }else if(cookie[0] == "Res_Last"){
  81. MyCookies_Recipe.Res_Last = parseInt(cookie[1]);
  82. }else if(cookie[0] == "Res_Checked"){
  83. MyCookies_Recipe.Res_Checked = parseInt(cookie[1]);
  84. }else if(cookie[0] == "load_Music"){
  85. MyCookies_Recipe.load_Music = cookie[1];
  86. }else if(cookie[0] == "volume_Music"){
  87. MyCookies_Recipe.volume_Music = parseInt(cookie[1]);
  88. }else if(cookie[0] == "reload_Time"){
  89. MyCookies_Recipe.reload_Time = parseInt(cookie[1]);
  90. }
  91. }
  92. }
  93. return true;
  94. }
  95. //レスチェック時の差分の判断関数
  96. function ResChecked_sabun(arg){
  97. if(arg == 0){
  98. document.getElementById("resInfoTxt").innerHTML = "おしらせ:現在未読はありません";
  99. return true;
  100. }else if(arg > 0){
  101. document.getElementById("resInfoTxt").innerHTML = "おしらせ:未読が" + arg + "件あります";
  102. return true;
  103. }else{
  104. document.getElementById("resInfoTxt").innerHTML = "おしらせ:ResCheckError";
  105. return false;
  106. }
  107. }
  108. //レス確認のボタンを押した時(.resInfoBtn.onclick)
  109. function resetResChecked(MyCookies_Recipe){
  110. MyCookies_Recipe.Res_Checked = MyCookies_Recipe.Res_Last;
  111. ResChecked_sabun(0);
  112. makeCookie(MyCookies_Recipe);
  113. return true;
  114. }
  115. //I/Oフォーム(上部追加分)のひな形用関数
  116. function IOForm_hinagata(MyCookies_Recipe){
  117. var IOFormHeaderCenter = document.createElement("center");
  118. var IOFormHeader = document.createElement("div");
  119. IOFormHeader.id = "IOFormHeader";
  120. var resInfo = document.createElement("div");
  121. resInfo.id = "resInfo";
  122. var resInfoBtn = document.createElement("input");
  123. resInfoBtn.id = "resInfoBtn";
  124. resInfoBtn.className = "SidebySide";
  125. resInfoBtn.type = "button";
  126. resInfoBtn.value = "確認";
  127. resInfoBtn.onclick = function(){resetResChecked(MyCookies_Recipe);};
  128. var resInfoTxt = document.createElement("div");
  129. resInfoTxt.id = "resInfoTxt";
  130. resInfoTxt.className = "SidebySide";
  131. document.body.insertBefore(IOFormHeaderCenter,document.body.firstChild);
  132. IOFormHeaderCenter.appendChild(IOFormHeader);
  133. IOFormHeader.appendChild(resInfo);
  134. resInfo.appendChild(resInfoTxt);
  135. resInfo.appendChild(resInfoBtn);
  136. return IOFormHeader;
  137. }
  138. //リロード時の関数
  139. function funcExit(){
  140. window.stop(); //一旦読み込み中止してからでないと、次に上手く読み込まない?
  141. location.reload(true); //キャッシュは破棄してリロード
  142. }
  143. //CSS追加用関数
  144. function addGlobalStyle(css) { // Head部分にstyleを追加する関数
  145. var head, style;
  146. head = document.getElementsByTagName('head')[0]; // head要素を取る
  147. if (!head) { return }
  148. style = document.createElement('style'); // 要素styleをつくる
  149. style.type = 'text/css'; // styleの属性typeを追加
  150. style.innerHTML = css; // styleの属性として引数cssを追加
  151. head.appendChild(style); // headの中に要素styleを追加する
  152. }
  153. //追加CSS
  154. addGlobalStyle('.SidebySide {display : inline-block;font-size: small; }');
  155. //本文
  156. //Cookieの取得(設定データ)
  157. eatCookie(Cookies_Recipe);
  158. //リロード時間はここで先に指定
  159. var Timer = setTimeout(funcExit,Cookies_Recipe.reload_Time * 1000);
  160.  
  161. //事前に音声を取得
  162. var audio = new Audio(Cookies_Recipe.load_Music);
  163. audio.volume = Cookies_Recipe.volume_Music / 100.;
  164.  
  165. //page内の最新レス番号を取得
  166. var Res_Now = load_ResNo();
  167. if(Res_Now == 0 || Res_Now == 1){
  168. alert("仕様変更?\n製作者に連絡ください\n(Res_Now = " + Res_Now + ")");
  169. return 0;
  170. }
  171. else{
  172. //ひな形の作成
  173. var IOForm = IOForm_hinagata(Cookies_Recipe);
  174. //URLに対応したCookieがなければ、新たに作る
  175. if(Cookies_Recipe.load_URL == location.href){
  176. if(Cookies_Recipe.Res_Last != Res_Now){
  177. audio.play();
  178. Cookies_Recipe.Res_Last = Res_Now;
  179. }
  180. ResChecked_sabun(Res_Now - Cookies_Recipe.Res_Checked);
  181. }else{
  182. Cookies_Recipe.load_URL = location.href;
  183. Cookies_Recipe.Res_Last = Res_Now;
  184. Cookies_Recipe.Res_Checked = Res_Now;
  185. ResChecked_sabun(Res_Now - Cookies_Recipe.Res_Checked);
  186. }
  187. makeCookie(Cookies_Recipe);
  188. }
  189. })()