スキップしてメイン コンテンツに移動

Operaで使えるニコニコ大百科ポップアップ

超うそ臭いの作ってみた。
元ネタはこちらのページ
コードをまるっとコピペした。
後、iframeを動的に追加して、dic.nicovideo.jpを表示させた。んで、説明文を適当に切り張りしてる。
つまるところ、無駄にインフラを消費するという素敵無駄コード!!
変な関数とかは使っていないので、FirefoxやGoogle Chromeで動くかもしれません。
動いても嘘くさい動きですががが。
ポップアップは自動的には消えないので、適当に左上の×ボタン(?)をクリックしてください。
mouseoutで消しやがれF*ckって人は適当にコードいじってください。

// ==UserScript==
// @name Popup Nico Dict for Iframe
// @namespace http://gigi-net.net
// @include http://dic.nicovideo.jp/*
// @include http://www.nicovideo.jp/watch/*
// @author giginet modified Arc Cosine
// @version 1.0
// ==/UserScript==
(function(){
var nicodicView = {
tip : null,
init : function(){
if( this.checkOption() ){
this.createNicoDic();
}else{
this.popup();
}
},
createNicoDic : function(){
document.getElementById("container").style.display = 'none';
//clear div
var cap = document.getElementsByTagName("h1")[0].innerHTML;
var desc = document.getElementById("article");
var article= desc.innerHTML;

//ページメニューを消去
article =article.replace(/<div id..page-menu.>.*<.div>/i,"");

//見出しを【】に変換
article =article.replace(/<h2.*?>/gm,"【");
article =article.replace(/<.h2>/gm,"】");

//タグを全消去
article =article.replace(/<.*?>/mg,"");
//先頭300文字のみ抽出し、省略された場合は...をくわえる
showText =article.substring(0,299);
if(article.length>=300){
showText +="..."
}
//見出しを改行する
showText =showText.replace(/【/gm,"<br>【");
showText =showText.replace(/】/gm,"】<br>");
//タイトルを追加
showText ="<h1>"+cap+"</h1>"+showText;
var descDiv = document.body.appendChild(document.createElement('div'));
descDiv.style.display = 'block';
descDiv.innerHTML = showText;
},
popup : function(){
var loc = location.href.match(/nicovideo/);
if(loc){
var iconList = document.getElementsByClassName("txticon");
var _self = this;
for( var i=0, l=iconList.length; i<l; i++ ) (function(list){
_self.CoolTips(list);
})(iconList[i]);
}
},
checkOption : function(){
var loc =location.href.match(/popup=true/);
if( !loc ){
return false;
}
return true;
},
findPos : function(e){
return { "x":e.clientX, "y":e.clientY};
},
CoolTips : function(node){
var link = node.parentNode.href;
node.onmouseover = function(e){ nicodicView.showTips(e,link); };
//node.onmouseout = function(){ nicodicView.hideTips(); };
},
showTips : function(e,link){
if( this.tip != null ){ this.nicodicView.hideTips(); };
this.tip = document.createElement("div");
var pos = this.findPos(e);
this.tip.style.top = pos.y - 240 +'px';
this.tip.style.left = pos.x + 20 + 'px';
this.tip.style.width = '340px';
this.tip.style.height = '220px';
this.tip.style.fontSize = '13px';
this.tip.style.fontWeight = 'bold';
this.tip.style.zIndex = '10000';
this.tip.style.background = "#333333";
this.tip.style.color = "#ffffff";
this.tip.style.position = 'absolute';


var iframe = this.tip.appendChild(document.createElement("iframe"));
iframe.src = link + "?popup=true";
iframe.width = "100%";
iframe.height= "100%";

var closeBox = this.tip.appendChild(document.createElement("div"));
closeBox.style.position = 'absolute';
closeBox.style.top = "2px";
closeBox.style.marginLeft = "2px";
closeBox.style.border = "sold 1px #fcfcfc";
closeBox.style.zIndex = "10001";
closeBox.style.width = '16px';
closeBox.style.height = '16px';
closeBox.style.background= '#333333';
closeBox.style.color= '#ffffff';
closeBox.style.fontWeight= 'bold';
closeBox.appendChild(document.createTextNode('X'));
closeBox.onclick = function(){ nicodicView.hideTips() };
document.body.appendChild(this.tip);

},
hideTips : function(){
this.tip.parentNode.removeChild(this.tip);
this.tip = null;
}

};
nicodicView.init();
})();

コメント

このブログの人気の投稿

EFIブートローダを移動した話

EFIブートローダを移動した HX90に環境を整え終わってから、アホな事をしたので、その記録を残す。 SSD: Cドライブ SSD: Dドライブ(データストレージ用) + ESP※ SSD: Eドライブ(データストレージ用) ※ESP(EFI System Partition) インストールした時、こんな構成だった。 ESPがDドライブにあるのが気持ち悪かったので、これを削除した。 そしたら、BIOS画面が出るだけになり、Windowsが起動しなくなった。 移動手順 この時の自分はMBRをふっ飛ばした時と同じ現象だと思ったので、MBRというキーワードで検索したが、今はEFIブートローダーと呼んでいるらしい。 【Win10】任意のディスクにEFIブートローダをインストールする 色々検索した結果この記事が参考になった。 Diskpartを使って、パーティションを新たに分割し、bcdbootを実行して、無事に事なきを得た。 パーティションの分割はこんな感じ Diskpart Select volume 0 shrink desired = 200 Select disk 0 Create partition EFI size=200 Format quick fs=fat32 label="ESP" Assign letter=P exit EFIブートローダーのインストールはこんな感じ bcdboot C:\Windows /s P: /f UEFI ちなみに、自分の環境だけの問題なのだが、コマンドラインで、「\」を入力するのができなかった。我が家のキーボードはHHKBだけなので、日本語配列を無理やり適用されると、バックスラッシュが入力できないという不具合が生じる。 結局、コマンドプロンプトからマウスで範囲選択してコピーして貼り付けるという荒業でクリアした。 普通の人は、何も考えずに、\を入力すれば良い。 最終的に SSD: Cドライブ + ESP※ SSD: Dドライブ(データストレージ用) SSD: Eドライブ(データストレージ用) ※ESP(EFI System Partition) という構成に切り替えることができた。

PlemolJP導入

PlemolJP を導入した 思い立つことがあり、 PlemolJP をインストールする事にした。 自分は、PowerLine を使っているので、PlemolJP Nerd Fonts 版である、PlemolJP_NF をダウンロードしてインストールした PlemolJP の releases から、PlemolJP_NF_vx.x.x.zip をダウンロードする。 zip を展開し、PlemolJPConsoleNF-Regular.ttf をインストールする set guifont=PlemolJP_Console_NF:h18 を gvimrc に書く(フォントサイズはお好きに) ちなみに、これは Windows 限定の設定なので、Mac や Linux などで導入する際には、別の方法をオススメする。 余談 gvimrc に指定するフォント名が微妙にわかりづらい。 普段は、 set guioptions-=m してメニューバーは出していないが、今回は :set guioptions+=m を実行して、編集 → フォント設定からフォントを選び、フォント名に入力されている文字列をコピペして、スペース部分をアンダースコアで置き換えた。 この辺のルールとかに詳しい人にぜひとも教えて欲しい所。 導入した感想 今までの Powerline フォントはいまいちなのが多かったが、PlemolJP の表示は非常に良い。 今後はこちらをメインで使って行きたい。 あと、僕はヱビス派です。