Swap two divs inside a parent
Устаревшая версия за
// ==UserScript==
// @name Show Deleted Answers/Questions at head for StackExchange
// @namespace http://tampermonkey.net/
// @version 1.2.4
// @description Swap two divs inside a parent
// @author aspen138
// @match https://*.stackexchange.com/users/*/*?tab=answers*
// @match https://*.stackexchange.com/users/*/*?tab=questions*
// @match https://mathoverflow.net/users/*/*?tab=answers*
// @match https://mathoverflow.net/users/*/*?tab=questions*
// @match https://stackoverflow.com/users/*/*?tab=answers*
// @match https://stackoverflow.com/users/*/*?tab=questions*
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/questions/*
// @match *://superuser.com/questions/*
// @match *://meta.superuser.com/questions/*
// @match *://serverfault.com/questions/*
// @match *://meta.serverfault.com/questions/*
// @match *://askubuntu.com/questions/*
// @match *://meta.askubuntu.com/questions/*
// @match *://mathoverflow.net/questions/*
// @match *://meta.mathoverflow.net/questions/*
// @match *://*.stackexchange.com/questions/*
// @match *://answers.onstartups.com/questions/*
// @match *://meta.answers.onstartups.com/questions/*
// @match *://stackapps.com/questions/*
// @match *://*.stackoverflow.com/review/*
// @match *://superuser.com/review/*
// @match *://meta.superuser.com/review/*
// @match *://serverfault.com/review/*
// @match *://meta.serverfault.com/review/*
// @match *://askubuntu.com/review/*
// @match *://meta.askubuntu.com/review/*
// @match *://mathoverflow.net/review/*
// @match *://meta.mathoverflow.net/review/*
// @match *://*.stackexchange.com/review/*
// @match *://answers.onstartups.com/review/*
// @match *://meta.answers.onstartups.com/review/*
// @match *://stackapps.com/review/*
// @match *://*.stackoverflow.com/search*
// @match *://superuser.com/search*
// @match *://meta.superuser.com/search*
// @match *://serverfault.com/search*
// @match *://meta.serverfault.com/search*
// @match *://askubuntu.com/search*
// @match *://meta.askubuntu.com/search*
// @match *://mathoverflow.net/search*
// @match *://meta.mathoverflow.net/search*
// @match *://*.stackexchange.com/search*
// @match *://answers.onstartups.com/search*
// @match *://meta.answers.onstartups.com/search*
// @match *://stackapps.com/search*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Function to swap divs
function swapDivs() {
let parentDiv = document.querySelector('.ba.bc-black-225.bar-md');
let firstDiv = document.querySelector('#js-post-summaries');
let secondDiv = document.querySelector('.bt.bc-black-200.p16');
if (parentDiv && firstDiv && secondDiv) {
let firstDivClone = firstDiv.cloneNode(true);
let secondDivClone = secondDiv.cloneNode(true);
parentDiv.removeChild(firstDiv);
parentDiv.removeChild(secondDiv);
parentDiv.appendChild(secondDivClone);
parentDiv.appendChild(firstDivClone);
}
}
// Swap divs on page load
window.addEventListener('load', swapDivs, false);
let tabs = document.querySelectorAll('.js-user-tab-sort');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
setTimeout(function(){ location.reload(); }, 0.3);
}, false);
});
})();