Greasy Fork is available in English.
解决 Opera Mobile Classic for Android 在 m.fanfou.com 上转发消息时在某些情况下缺字的问题
当前为
// ==UserScript==
// @name 饭否-解决Opera Mobile Classic转发消息漏字问题
// @version 1.0.1
// @author HackMyBrain
// @description 解决 Opera Mobile Classic for Android 在 m.fanfou.com 上转发消息时在某些情况下缺字的问题
// @include http://m.fanfou.com/*
// ==/UserScript==
(function (){
function saveFWContent(e){
if ( /\/msg\.forward\//.test(e.target.href) && e.target.innerHTML == '转发' ){
var target_post = e.target.parentElement.parentElement;
var post_content, postChildNode;
if ( /^\/statuses\//.test(location.pathname) ) {
var author = document.querySelector('b > a');
post_content = '';
postChildNode = author.parentElement;
}
else {
post_content = ( target_post.getElementsByClassName('p').length != 0 || /^\/mentions($|\/)/.test(location.pathname) )? '' : document.title.replace(/饭否 \| /,'') + ' ';
postChildNode = target_post.firstChild;
}
while ( postChildNode.className != 'stamp' && postChildNode.className != 't') {
post_content += (!postChildNode.title)? postChildNode.textContent : postChildNode.title;
postChildNode = postChildNode.nextSibling;
}
var mes_content = '转@' + post_content;
sessionStorage.setItem('_fw_fixer_', mes_content);
}
}
//私信框填入消息内容 & 光标定位于私信框开端(光标定位在Opera Mobile Classic下不成功)
function fillFWContent() {
if ( /\/msg\.forward\//.test(location.pathname) && !! sessionStorage.getItem('_fw_fixer_') ) {
var textarea = document.getElementsByTagName('textarea')[0];
textarea.value = ' ' + sessionStorage.getItem('_fw_fixer_'); //填写消息内容并在开头自动添加空格
sessionStorage.removeItem('_fw_fixer_');
textarea.focus();
textarea.setSelectionRange(0,0);
}
}
document.addEventListener('click', saveFWContent, false);
fillFWContent();
})();