Tieba Fix for Opera

Opera贴吧修复 - Gerald倾情打造

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name	Tieba Fix for Opera
// @namespace	http://gera2ld.blog.163.com/
// @author	Gerald <[email protected]>
// @icon	http://s.gravatar.com/avatar/a0ad718d86d21262ccd6ff271ece08a3?s=80
// @version	1.3.1
// @description	Opera贴吧修复 - Gerald倾情打造
// @homepage	http://userscripts.org/scripts/show/153687
// @include	http://tieba.baidu.com/*
// @exclude	http://tieba.baidu.com/tb/*
// @require	https://greatest.deepsurf.us/scripts/144/code.user.js
// ==/UserScript==

// 修复光标
function initCursorFix(editor) {
	UE.browser.opera=null;
	UE.browser.ie=true;
	UE.browser.ie9above=true;
}
// 修复粘贴功能
function initPasteFix() {
	$('<div id=baidu_pastebin>').appendTo(document.body);
}
// 修复上传图片错误
function initImageUpdateFix() {
	var loadingURL='http://tb2.bdstatic.com/tb/static-postor/images/loading_33e098e1.gif';
	unsafeWindow._.Module.use('common/component/image_uploader_manager',{},function(b){
		utils.hook(b.__proto__,'_startImageUploader',{after:function(){
			var i=$('<input type=file style="opacity:0">'),m=null;
			this._options.container.html(i);
			if(!('uploadImage' in utils)) m='请先安装贴吧图化脚本(http://userscripts.org/scripts/show/156579)才能上传本地图片!';
			else if(!utils.uploadImage) m='图片上传功能初始化失败,请在图化按钮中重试!';
			if(m) i.click(function(e){e.preventDefault();alert(m);});
			else i.change(function(e){
				var r=new FileReader(),i=document.createElement('img');
				i.src=loadingURL;test_editor.selection._bakRange.insertNode(i);
				r.onload=function(){utils.uploadImage(this.result,i);};
				r.readAsDataURL(e.target.files[0]);
			});
		}});
	});
}

if(unsafeWindow.PosterContext&&unsafeWindow.PosterContext.isPostAllowed()) {
	utils.wait(unsafeWindow,'test_editor',initCursorFix);	// 修复光标
	initPasteFix();		// 修复粘贴功能
	initImageUpdateFix();		// 修复上传图片错误
}