Show/Hide all posts on Voat

Adds a button which will "unfold" all artikles on the current Voat page.

目前為 2015-06-19 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Show/Hide all posts on Voat
  3. // @namespace https://voat.co/user/Grischinka
  4. // @version 0.1
  5. // @description Adds a button which will "unfold" all artikles on the current Voat page.
  6. // @author Grischinka
  7. // @match https://voat.co/*
  8. // @grant none
  9. // @licence Public Domain
  10. // ==/UserScript==
  11.  
  12. function getElementByXpath(path) {
  13. return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  14. }
  15.  
  16. // Add a button to the Header
  17. var tabBar = getElementByXpath('//*[@id="header-banner"]/ul');
  18. var toggleButton = document.createElement("BUTTON");
  19. //toggleButton.className = 'contribute submit-text';
  20. var toggleText = document.createTextNode("View/Hide All");
  21. toggleButton.appendChild(toggleText);
  22. toggleButton.style.border = 'none';
  23.  
  24. var tabListElement = document.createElement("li");
  25.  
  26.  
  27. tabBar.appendChild(toggleButton);
  28.  
  29. toggleButton.onclick=function(){
  30. var expandobtns = document.getElementsByClassName('expando-button');
  31. for (i = 0; i < expandobtns.length; i++) {
  32. expandobtns[i].click();
  33. }
  34. }