CustomGinnamaWatch

ニコニコ生放送:GINZAの生放送プレイヤーのUIをお手軽カスタマイズ。

当前为 2015-09-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CustomGinnamaWatch
  3. // @include http://live.nicovideo.jp/watch/*
  4. // @version 2.0.4.1
  5. // @namespace http://d.hatena.ne.jp/wfwjfow/
  6. // @description ニコニコ生放送:GINZAの生放送プレイヤーのUIをお手軽カスタマイズ。
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9.  
  10. // ==/UserScript==
  11. /*
  12. ■参考スクリプト
  13. NicoRankingKidokuDelete → http://userscripts.org/scripts/show/45927
  14. ■参考サイト
  15. http://userscripts.org/topics/43597
  16. http://stackoverflow.com/questions/2246901/how-can-i-use-jquery-in-greasemonkey-scripts-in-google-chrome
  17. http://www.webopixel.net/javascript/160.html
  18. */
  19.  
  20.  
  21. (function() {
  22.  
  23. if ((typeof GM_getValue == 'undefined') || (GM_getValue('a', 'b') == undefined)) {
  24.  
  25. GM_getValue = function(name, defaultValue) {
  26. var value = localStorage.getItem(name);
  27. if (!value)
  28. return defaultValue;
  29. var type = value[0];
  30. value = value.substring(1);
  31. switch (type) {
  32. case 'b':
  33. return value == 'true';
  34. case 'n':
  35. return Number(value);
  36. default:
  37. return value;
  38. }
  39. }
  40. GM_setValue = function(name, value) {
  41. value = (typeof value)[0] + value;
  42. localStorage.setItem(name, value);
  43. }
  44. if(typeof(unsafeWindow)=='undefined') { unsafeWindow=window; }
  45. }
  46.  
  47. //ウォール消去
  48. function walloff(){
  49. if( GM_getValue("walloff")=="on"){
  50. var oStyle = document.createElement('style');
  51. oStyle.setAttribute('type','text/css');
  52. var css = '#wall_canvas{display:none!important;}#wall_chip_area{display:none!important;}';
  53. oStyle.innerHTML = css;
  54. document.getElementsByTagName('head')[0].appendChild(oStyle);
  55. }
  56. }
  57. //広告消去
  58. function senCut2(){
  59. if( GM_getValue("senden2")=="on"){
  60. var oStyle = document.createElement('style');
  61. oStyle.setAttribute('type','text/css');
  62. var css = '#ad_bnr,#footer_ads,#jsFollowingAdContent{display:none!important;}';
  63. oStyle.innerHTML = css;
  64. document.getElementsByTagName('head')[0].appendChild(oStyle);
  65. }
  66. }
  67. //宣伝ボタン消去
  68. function senCut3(){
  69. if( GM_getValue("senden3")=="on"){
  70. var oStyle = document.createElement('style');
  71. oStyle.setAttribute('type','text/css');
  72. var css = '#watch_title_box .niconikoukoku{display:none!important;}';
  73. oStyle.innerHTML = css;
  74. document.getElementsByTagName('head')[0].appendChild(oStyle);
  75. }
  76. }
  77. //フッター消去
  78. function footcut(){
  79. if( GM_getValue("footer_off")=="on"){
  80. var oStyle = document.createElement('style');
  81. oStyle.setAttribute('type','text/css');
  82. var css = '#page_footer,#body_footer_wrap{display:none!important;}';
  83. oStyle.innerHTML = css;
  84. document.getElementsByTagName('head')[0].appendChild(oStyle);
  85.  
  86. if(window.parent.location.href.slice(0,35)=="http://live.nicovideo.jp/watch/nsen"){
  87. var pstyle = document.createElement('style');
  88. pstyle.setAttribute('type','text/css');
  89. var css2 = '#utility_link,#page_footer,#body_footer_wrap{display:none!important;}';
  90. pstyle.innerHTML = css2;
  91. document.getElementsByTagName('head')[0].appendChild(pstyle);
  92. }
  93. }
  94. }
  95. //ヘッダー消去
  96. function headcut(){
  97. if( GM_getValue("head_off")=="on"){
  98.  
  99. var menu=document.getElementById("qnama");
  100. //menu.innerHTML="■";
  101. document.body.appendChild(menu);
  102.  
  103. var oStyle = document.createElement('style');
  104. oStyle.setAttribute('type','text/css');
  105. var css = '#siteHeader{display:none!important;}body{padding-top:0!important;}#qnama{background-color:#fb2db8;position:fixed;top:0;font-size:0px;display:block;width:100%;height:5px;z-index:999999999;cursor:pointer;margin-left:0!important;}';
  106. oStyle.innerHTML = css;
  107. document.getElementsByTagName('head')[0].appendChild(oStyle);
  108. }
  109. }
  110. //市場消去
  111. function ichibaCut(){
  112. if( GM_getValue("ichiba_off")=="on"){
  113. var oStyle = document.createElement('style');
  114. oStyle.setAttribute('type','text/css');
  115. var css = '#advertisement_box{display:none!important;}div#watch_tab_box{background:transparent!important;}';
  116. oStyle.innerHTML = css;
  117. document.getElementsByTagName('head')[0].appendChild(oStyle);
  118. }
  119. }
  120. //ザッピングを消去
  121. function zappingCut(){
  122. if( GM_getValue("zapping_off")=="on"){
  123. var oStyle = document.createElement('style');
  124. oStyle.setAttribute('type','text/css');
  125. var css = '#watch_zapping_box{display:none!important;}';
  126. oStyle.innerHTML = css;
  127. document.getElementsByTagName('head')[0].appendChild(oStyle);
  128.  
  129. if(window.parent.location.href.slice(0,35)=="http://live.nicovideo.jp/watch/nsen"){
  130. var pstyle = document.createElement('style');
  131. pstyle.setAttribute('type','text/css');
  132. var css2 = '{display:none!important;}';
  133. pstyle.innerHTML = css2;
  134. document.getElementsByTagName('head')[0].appendChild(pstyle);
  135. }
  136. }
  137. }
  138. //使い方・共有等を消去
  139. function helpCut(){
  140. if( GM_getValue("help_off")=="on"){
  141. var oStyle = document.createElement('style');
  142. oStyle.setAttribute('type','text/css');
  143. var css = '#watch_player_bottom_box{display:none!important;}';
  144. oStyle.innerHTML = css;
  145. document.getElementsByTagName('head')[0].appendChild(oStyle);
  146.  
  147. if(window.parent.location.href.slice(0,35)=="http://live.nicovideo.jp/watch/nsen"){
  148. var pstyle = document.createElement('style');
  149. pstyle.setAttribute('type','text/css');
  150. var css2 = '#player_btm{display:none!important;}div#reqBoxRule{display:none!important;}#mylistArea{margin:0!important;padding:0!important;}';
  151. pstyle.innerHTML = css2;
  152. document.getElementsByTagName('head')[0].appendChild(pstyle);
  153. }
  154. }
  155. }
  156. //PAGE TOPを消去
  157. function pagetopCut(){
  158. if( GM_getValue("pagetop_off")=="on"){
  159. var oStyle = document.createElement('style');
  160. oStyle.setAttribute('type','text/css');
  161. var css = '.page_top{display:none!important;}';
  162. oStyle.innerHTML = css;
  163. document.getElementsByTagName('head')[0].appendChild(oStyle);
  164. }
  165. }
  166. //背景灰色
  167. function backwhite(){
  168. if( GM_getValue("back_off")=="on"){
  169. if(window.parent.location.href.slice(0,35)!="http://live.nicovideo.jp/watch/nsen"){
  170. var oStyle = document.createElement('style');
  171. oStyle.setAttribute('type','text/css');
  172. var css = 'body,#all_cover,#all,div#watch_title_box,#watch_player_top_box,div#watch_player_top_box div,div#watch_player_box,div#watch_zapping_box,div#page_header,div#page_cover{background:#F4F4F4!important;border:none!important;}#page *{text-shadow:none!important;color:#000000!important;font-size:13px!important;}';
  173. oStyle.innerHTML = css;
  174. document.getElementsByTagName('head')[0].appendChild(oStyle);
  175. }
  176. }
  177. }
  178. //ロゴ・検索ボックス消去
  179. function logoCut(){
  180. if( GM_getValue("logo_off")=="on"){
  181. var oStyle = document.createElement('style');
  182. oStyle.setAttribute('type','text/css');
  183. var css = '#page_header{display:none!important;}#page_cover{margin-top:0px!important;}';
  184. oStyle.innerHTML = css;
  185. document.getElementsByTagName('head')[0].appendChild(oStyle);
  186.  
  187. if(window.parent.location.href.slice(0,35)=="http://live.nicovideo.jp/watch/nsen"){
  188. var pstyle = document.createElement('style');
  189. pstyle.setAttribute('type','text/css');
  190. var css2 = 'div.headerInner{display:none!important;}div#header{margin-top:20px!important;}';
  191. pstyle.innerHTML = css2;
  192. document.getElementsByTagName('head')[0].appendChild(pstyle);
  193. }
  194. }
  195. }
  196. //ページ左右余白リンク消去
  197. function dellink(){
  198. if( GM_getValue("link_off")=="on"){
  199. if(window.parent.location.href.slice(0,35)!="http://live.nicovideo.jp/watch/nsen"){
  200. var divleft=document.createElement("div");
  201. var divright=document.createElement("div");
  202. divleft.id="divleft";
  203. divright.id="divright";
  204. document.body.appendChild(divleft);
  205. document.body.appendChild(divright);
  206. var divwidth=parseInt( (document.body.clientWidth-960)/2 +1 );
  207. divleft.style.width=divwidth+"px";
  208. divright.style.width=divwidth+"px";
  209.  
  210. var oStyle = document.createElement('style');
  211. oStyle.setAttribute('type','text/css');
  212. var css = '#divleft{position:absolute;top:0;left:0;height:100%;background-color:#F4F4F4;z-index:9999999;}#divright{position:absolute;top:0;right:0;height:100%;background-color:#F4F4F4;z-index:9999999;}#siteHeader #siteHeaderInner{width:984px!important;}';
  213. oStyle.innerHTML = css;
  214. document.getElementsByTagName('head')[0].appendChild(oStyle);
  215.  
  216. var pagewidth=parseInt( (document.body.clientWidth-960)/2 +1 );
  217. document.getElementById("prefDiv").style.right=pagewidth+"px";
  218. }
  219. }
  220. }
  221. //ニュース消去
  222. function delnews(){
  223. if( GM_getValue("news_off")=="on"){
  224. if(window.parent.location.href.slice(0,35)!="http://live.nicovideo.jp/watch/nsen"){
  225. var divsus=document.createElement("div");
  226. divsus.id="divsus";
  227. document.body.appendChild(divsus);
  228. //<h1 id="element-h1">指定要素</h1>
  229. var elm = document.getElementById("slider_container");
  230.  
  231. //[getBoundingClientRect]を参照する
  232. var rect = elm.getBoundingClientRect() ;
  233.  
  234. //ブラウザの左上からのX座標を取得する
  235. var positionX = rect.left ;
  236.  
  237. //ブラウザの左上からのY座標を取得する
  238. var positionY = rect.top ;
  239.  
  240. //スクロール量の取得に必要なパーツ
  241. var dElm = document.documentElement , dBody = document.body;
  242.  
  243. //X方向のスクロール量を取得する
  244. var scrollX = dElm.scrollLeft || dBody.scrollLeft ;
  245.  
  246. //Y方向のスクロール量を取得する
  247. var scrollY = dElm.scrollTop || dBody.scrollTop ;
  248.  
  249. //要素のX座標
  250. var x = positionX + scrollX ;
  251.  
  252. //要素のY座標
  253. var y = positionY + scrollY ;
  254.  
  255. var winwidth=parseInt( (document.body.clientWidth-960)/2 +1 );
  256.  
  257. divsus.style.top=y+22+"px";
  258. divsus.style.left=x+winwidth+"px";
  259.  
  260.  
  261. var oStyle = document.createElement('style');
  262. oStyle.setAttribute('type','text/css');
  263. var css = '#divsus{position:absolute;background-color:#F4F4F4;z-index:9999999;width:680px;height:60px;}';
  264. oStyle.innerHTML = css;
  265. document.getElementsByTagName('head')[0].appendChild(oStyle);
  266.  
  267. }
  268. }
  269. }
  270.  
  271.  
  272.  
  273.  
  274.  
  275. function labelElement(str,che){
  276. var k = document.createElement("label");
  277. k.innerHTML = str;
  278. k.style.cursor = "hand";
  279. k.setAttribute("for",che);
  280. k.style.fontSize = "12px";
  281. return k;
  282. }
  283.  
  284. function interface_kidoku(){
  285. var prefDiv = document.createElement("div");
  286. prefDiv.style.width = "300px";
  287. prefDiv.style.height = "250px";
  288. prefDiv.style.overflowY = "scroll";
  289. prefDiv.innerHTML = "GinnamaWatchカスタマイズ設定" + "<br>";
  290. prefDiv.style.backgroundColor = "#ccccff";
  291. prefDiv.style.color = "black";
  292. prefDiv.style.border = "1px solid #888";
  293. prefDiv.style.position = "fixed";
  294. prefDiv.style.bottom = "0px";
  295. prefDiv.style.right = "0px";
  296. prefDiv.style.textAlign = 'left';
  297. prefDiv.style.margin = "0 0 0 0";
  298. prefDiv.style.zIndex = 999;
  299. prefDiv.style.display =
  300. (GM_getValue("prefDisplay") == "none") ? "none" : "";
  301. prefDiv.id = "prefDiv";
  302. document.body.appendChild(prefDiv);
  303.  
  304. var tojiru=document.createElement("div");
  305. tojiru.innerHTML = "閉じる";
  306. tojiru.style.position = "absolute";
  307. tojiru.style.top = "0px";
  308. tojiru.style.right = "5px";
  309. tojiru.style.color="#00BFFF";
  310. tojiru.style.cursor = "pointer";
  311. tojiru.id="tojiru";
  312.  
  313.  
  314. var linkwalloff = document.createElement("input");
  315. linkwalloff.name = "walloff";
  316. linkwalloff.caption = "ウォール消去";
  317. var linkSen2 = document.createElement("input");
  318. linkSen2.name = "senden2";
  319. linkSen2.caption = "Flash上以外の広告を消去";
  320. var linkichiba = document.createElement("input");
  321. linkichiba.name = "ichiba_off";
  322. linkichiba.caption = "市場消去";
  323. var linksencut = document.createElement("input");
  324. linksencut.name = "senden3";
  325. linksencut.caption = "宣伝ボタン消去";
  326. var linklist = document.createElement("input");
  327. linklist.name = "zapping_off";
  328. linklist.caption = "ザッピングを消去";
  329. var linkfootcut = document.createElement("input");
  330. linkfootcut.name = "footer_off";
  331. linkfootcut.caption = "フッター消去";
  332. var linkwhite = document.createElement("input");
  333. linkwhite.name = "back_off";
  334. linkwhite.caption = "背景を灰色にする";
  335. var linkhelp = document.createElement("input");
  336. linkhelp.name = "help_off";
  337. linkhelp.caption = "使い方・共有等を消去";
  338. var linkpagetop = document.createElement("input");
  339. linkpagetop.name = "pagetop_off";
  340. linkpagetop.caption = "PAGETOPを消去";
  341. var linklogocut = document.createElement("input");
  342. linklogocut.name = "logo_off";
  343. linklogocut.caption = "ロゴ・検索ボックス消去";
  344. var linkdellink = document.createElement("input");
  345. linkdellink.name = "link_off";
  346. linkdellink.caption = "ページ左右余白リンクを消去";
  347. var linkheadcut = document.createElement("input");
  348. linkheadcut.name = "head_off";
  349. linkheadcut.caption = "ヘッダー消去";
  350. var linkdelnews = document.createElement("input");
  351. linkdelnews.name = "news_off";
  352. linkdelnews.caption = "ニュース消去(テスト版)";
  353.  
  354. var form = document.createElement("form");
  355.  
  356. var links =
  357. [linkSen2,linkichiba,linkfootcut,linkwhite,linklist,linkhelp,linkpagetop,linkdellink,linklogocut,linkheadcut,linkwalloff,linksencut,linkdelnews];
  358.  
  359. for (var i=0;i<links.length;i++){
  360. links[i].type = "checkbox";
  361. links[i].defaultValue = "off";
  362. }
  363.  
  364. for (var i=0;i<links.length;i++){
  365. if (!GM_getValue(links[i].name)) {
  366. GM_setValue(links[i].name, links[i].defaultValue);
  367. }
  368. links[i].id = links[i].name;
  369. links[i].checked = (GM_getValue(links[i].name) != "on") ? false : true;
  370. links[i].addEventListener("click", function(e){
  371. GM_setValue(this.name, (GM_getValue(this.name) != "on") ? "on" : "off");
  372. }, true);
  373. }
  374.  
  375. //登録
  376. form.appendChild(tojiru);
  377. form.appendChild(document.createElement("br"));
  378. form.appendChild(linkSen2);
  379. form.appendChild(labelElement(linkSen2.caption, linkSen2.id));
  380. form.appendChild(document.createElement("br"));
  381. form.appendChild(linksencut);
  382. form.appendChild(labelElement(linksencut.caption, linksencut.id));
  383. form.appendChild(document.createElement("br"));
  384. form.appendChild(linkwalloff);
  385. form.appendChild(labelElement(linkwalloff.caption, linkwalloff.id));
  386. form.appendChild(document.createElement("br"));
  387. form.appendChild(linkheadcut);
  388. form.appendChild(labelElement(linkheadcut.caption, linkheadcut.id));
  389. form.appendChild(document.createElement("br"));
  390. form.appendChild(linkfootcut);
  391. form.appendChild(labelElement(linkfootcut.caption, linkfootcut.id));
  392. form.appendChild(document.createElement("br"));
  393. form.appendChild(linklist);
  394. form.appendChild(labelElement(linklist.caption, linklist.id));
  395. form.appendChild(document.createElement("br"));
  396. form.appendChild(linkhelp);
  397. form.appendChild(labelElement(linkhelp.caption, linkhelp.id));
  398. form.appendChild(document.createElement("br"));
  399. form.appendChild(linkichiba);
  400. form.appendChild(labelElement(linkichiba.caption, linkichiba.id));
  401. form.appendChild(document.createElement("br"));
  402. form.appendChild(linkpagetop);
  403. form.appendChild(labelElement(linkpagetop.caption, linkpagetop.id));
  404. form.appendChild(document.createElement("br"));
  405. form.appendChild(linkwhite);
  406. form.appendChild(labelElement(linkwhite.caption, linkwhite.id));
  407. form.appendChild(document.createElement("br"));
  408. form.appendChild(linklogocut);
  409. form.appendChild(labelElement(linklogocut.caption, linklogocut.id));
  410. form.appendChild(document.createElement("hr"));
  411. form.appendChild(linkdellink);
  412. form.appendChild(labelElement(linkdellink.caption, linkdellink.id));
  413. form.appendChild(document.createElement("hr"));
  414. form.appendChild(linkdelnews);
  415. form.appendChild(labelElement(linkdelnews.caption, linkdelnews.id));
  416.  
  417. prefDiv.appendChild(form);
  418.  
  419. var prefSw = document.createElement("span");
  420. prefSw.innerHTML = "カスタマイズ設定";
  421. prefSw.id = "qnama";
  422. prefSw.addEventListener("click",function(e){
  423. prefDiv.style.display =
  424. (prefDiv.style.display == "") ? "none" : "";
  425. GM_setValue("prefDisplay",prefDiv.style.display);
  426. },false);
  427. document.getElementById("siteHeaderRightMenuContainer").appendChild(prefSw);
  428.  
  429. tojiru.addEventListener("click",function(e){
  430. prefDiv.style.display =
  431. (prefDiv.style.display == "") ? "none" : "";
  432. GM_setValue("prefDisplay",prefDiv.style.display);
  433. },false);
  434.  
  435.  
  436. var oStyle = document.createElement('style');
  437. oStyle.setAttribute('type','text/css');
  438. var css = '#siteHeader #siteHeaderInner{width:85%!important;}#qnama{margin-left:17px;color:#000000!important;cursor:pointer;}#prefDiv hr{margin:5px 0;border-color:#333333;}';
  439. oStyle.innerHTML = css;
  440. document.getElementsByTagName('head')[0].appendChild(oStyle);
  441.  
  442.  
  443. }
  444.  
  445. interface_kidoku();
  446. senCut2();
  447. senCut3();
  448. zappingCut();
  449. footcut();
  450. backwhite();
  451. ichibaCut();
  452. helpCut();
  453. pagetopCut();
  454. logoCut();
  455. headcut();
  456. dellink();
  457. walloff();
  458. delnews();
  459.  
  460. })();