google plus rtl fix

Fix rtl in posts and comments in google plus

当前为 2016-10-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         google plus rtl fix
// @namespace    https://plus.google.com/105980437314936889817
// @version      0.3
// @description  Fix rtl in posts and comments in google plus
// @author       Javad
// @include      https://plus.google.com/*
// @include      https://plus.google.com
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    var text = document.querySelectorAll('div.ahil4d');
    var resharetext = document.querySelectorAll('.J3fjEb div');
    for (var i = 0; i < text.length; i++) {
        text[i].dir = "auto";
        console.log("fortext");
        resharetext[i].dir = "auto";
        console.log("forreshare");
    }
    var comment1 = document.querySelectorAll('.g6UaYd div');
    for (var k = 0; k < comment1.length; k++) {
        comment1[k].style.textAlign = "initial";
        console.log('comment');
    }

    var observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            mutation.addedNodes.forEach(function (node) {
                var reshare = node.querySelectorAll('div.ahil4d');
                var resharetop = node.querySelectorAll('.J3fjEb div');
                var comment = node.querySelectorAll('.g6UaYd div');
                var photo = node.querySelectorAll('.mUbCce.fKz7Od');
                if (reshare !== null) {
                    for (var a = 0; a < reshare.length; a++) {
                        reshare[a].dir = "auto";
                        console.log('reshare');
                    }
                }
                if (resharetop !== null) {
                    for (var b = 0; b < resharetop.length; b++) {
                        resharetop[b].dir = "auto";
                        console.log('resharetop');

                    }
                }
                if (comment !== null) {
                    for (var j = 0; j < comment.length; j++) {
                        comment[j].style.textAlign = "initial";
                        console.log('comment');

                    }
                }
                if (photo !== null) {
                    for (var d = 0; d < photo.length; d++) {
                        photo[d].tabIndex = "-1";
                        console.log('photo');
                    }
                } else {
                    console.log("notfound");
                }
            });
        });
    });
    observer.observe(document, {
        childList : true,
        subtree : true,
        attributes : true,
        characterData : false,
    });
})();