Make Google Tasks Great Again

Shows the embedded Google Tasks page on an own page

目前為 2020-06-16 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Make Google Tasks Great Again
// @author       CennoxX
// @contact      [email protected]
// @namespace    https://gf.qytechs.cn/users/21515
// @description  Shows the embedded Google Tasks page on an own page
// @version      0.9.1
// @match        https://tasks.google.com/*
// @match        https://calendar.google.com/calendar/r?opentasks=1
// @run-at       document-start
// @grant        GM.addStyle
// @license      MIT
// @noframes
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
    'use strict';
    //redirect to correct page
    if (document.URL == "https://calendar.google.com/calendar/r?opentasks=1"){
        window.location.replace("https://tasks.google.com/embed/?origin=https://mail.google.com");
    }
    document.onreadystatechange = function () {
        switch (document.readyState){
            case "interactive":
                GM.addStyle("body{display:inherit!important;}");//display body
                GM.addStyle(".CTxcDf, .oXBvod, .Sze5Fc{width:100%;}");//full width for add task and done tasks
                GM.addStyle(".SSPGKf{width:100%;}");//left column width 100 % for small screens
                GM.addStyle("@media only screen and (min-width: 600px){.SSPGKf{width:50%;}}");//left column width 50 %
                GM.addStyle("@media only screen and (min-width: 850px){.SSPGKf{width:35%;}}");//left column width 35 %
                GM.addStyle(".llhEMd{width:100%;}");//right column width 35 % for small screens
                GM.addStyle("@media only screen and (min-width: 600px){.llhEMd{width:50%;left:auto;}}");//right column width 50 %, not till the left border of the page
                GM.addStyle("@media only screen and (min-width: 850px){.llhEMd{width:65%;left:auto;}}");//right column width 65 %, not till the left border of the page
                GM.addStyle(".Nm5pwe{width:236px;}");//set width of option box for tasks
                GM.addStyle(".JJouhd textarea{height:350px!important;}");//make textarea for tasks bigger
                GM.addStyle(".JXiZgd .DPvwYc:nth-child(1){transform: rotate(180deg);}");//set arrow of keymap in other direction
                var oldTitle = "";
                var mainLoop = setInterval(function(){
                    var tasks = document.querySelectorAll(".llhEMd.iWO5td");
                    var lastTask = tasks.length-1;
                    //set check button instead of arrow button
                    if (tasks[lastTask]){
                        tasks[lastTask].querySelector(".ISUyle .sm8sCf").innerHTML="";
                    }
                    //hide task if another one is opened
                    for (var i = 0; i < lastTask; i++){
                        //don't hide if the page is already hidden or last page is a popup
                        if (!tasks[i].style.display && (i != lastTask-1 || tasks[i+1].getAttribute("isfullscreen")=="true")){
                            tasks[i].style.display = "none";
                            var lastBack = tasks[lastTask].querySelector(".sm8sCf.dF4uEb");
                            if (!lastBack.onmouseup){
                                //click the first back button to remove all hidden tasks
                                lastBack.onmouseup=()=>{
                                    document.querySelector(".sm8sCf.dF4uEb").click();
                                };
                            }
                        }
                    }
                    //show current task list as document title
                    if (document.title != oldTitle || oldTitle == "Tasks"){
                        oldTitle = document.title;
                        var item = document.querySelector(".WG62mc");
                                document.title = item.innerText + " · Tasks";
                    }
                }, 50);
                break;
            case "complete"://fallback
                init();
                break;
        }
    };
    var init = function(){
        //hide error message
        GM.addStyle("#af-error-container{display:none}");
        GM.addStyle("body{background:inherit}");
        var div = document.querySelector("div");
        if ( div && div.getAttribute("id") == "af-error-container"){
            document.title="Tasks";//hide error in title
            window.location.replace("https://tasks.google.com/embed/?origin=https://mail.google.com");//redirect to correct page
        }
    };
    init();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址