Show Deleted Answers at head for StackExchange

Swap two divs inside a parent

当前为 2023-09-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Show Deleted Answers at head for StackExchange
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Swap two divs inside a parent
  6. // @author aspen138
  7. // @match https://*.stackexchange.com/users/*/*?tab=answers&sort=newest
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Your code here...
  16. window.addEventListener('load', function() {
  17. let parentDiv = document.querySelector('.ba.bc-black-100.bar-md');
  18. let firstDiv = document.querySelector('#js-post-summaries');
  19. let secondDiv = document.querySelector('.bt.bc-black-075.p16');
  20.  
  21. if (parentDiv && firstDiv && secondDiv) {
  22. parentDiv.removeChild(firstDiv);
  23. parentDiv.removeChild(secondDiv);
  24. parentDiv.appendChild(secondDiv);
  25. parentDiv.appendChild(firstDiv);
  26. }
  27. }, false);
  28.  
  29. })();