Route53 Truther

Speak truth about Route53

目前為 2021-05-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Route53 Truther
// @namespace    http://offby1.net/
// @version      0.1
// @description  Speak truth about Route53
// @author       Chris Rose
// @include     /^https:\/\/[a-z0-9.-]*console\.aws\.amazon\.com\/.*$/
// @include     /^https:\/\/[a-z0-9.-]*console\.amazonaws\.cn\/.*$/
// @include     /^https:\/\/[a-z0-9.-]*console\.amazonaws-us-gov\.com\/.*$/
// @grant        GM_log
// ==/UserScript==

(function() {
    'use strict';

    var MutationObserver = window.MutationObserver;
    var myObserver = new MutationObserver (mutationHandler);
    var obsConfig = {
        childList: true, attributes: true,
        subtree: true, attributeFilter: ['aria-expanded']
    };

    myObserver.observe(document, obsConfig);

})();

function mutationHandler(mutationRecords) {
    if (ready()) {
        makeAMove(rightThingWrongPlace(), rightPlace());
    }
}

function ready() {
    return document.getElementsByClassName("ico-networking").length == 1 &&
        document.getElementsByClassName("ico-networking")[0].parentElement.parentElement.getElementsByTagName("ol").length == 1 &&
        document.getElementsByClassName("ico-database").length == 1 &&
        document.getElementsByClassName("ico-database")[0].parentElement.parentElement.getElementsByTagName("ol").length == 1;
}

function rightThingWrongPlace() {
    var childrenOfTheWrongKind = document.getElementsByClassName("ico-networking")[0].parentElement.parentElement.getElementsByTagName("ol")[0].childNodes;
    return Array.from(childrenOfTheWrongKind).find(e => e.textContent == "Route 53");
}

function rightPlace() {
    return document.getElementsByClassName("ico-database")[0].parentElement.parentElement.getElementsByTagName("ol")[0];
}

function makeAMove(theThing, thePlace) {
    if (theThing === undefined || thePlace === undefined) {
        return;
    }

    thePlace.insertBefore(theThing, thePlace.firstChild);
}

QingJ © 2025

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