Tieba Fix for Opera

Opera贴吧修复 - Gerald倾情打造

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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();		// 修复上传图片错误
}