Tieba Fix for Opera

Opera贴吧修复 - Gerald倾情打造

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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