🔖 Reddit expando: auto make thumbs expandable
This commit is contained in:
parent
e61fdbdbd3
commit
0e9e91bf60
1 changed files with 6 additions and 9 deletions
|
|
@ -3,7 +3,7 @@
|
|||
// @namespace danielrayjones
|
||||
// @description Allow removal of visited links on Amazon Giveaway Listing
|
||||
// @include https://old.reddit.com*
|
||||
// @version 1.0.2
|
||||
// @version 1.0.3
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
|
|
@ -15,15 +15,17 @@
|
|||
|
||||
let para = document.createElement('p');
|
||||
let exButton = document.createElement('button');
|
||||
exButton.innerText = 'Expand images';
|
||||
exButton.innerText = 'Expand';
|
||||
exButton = para.appendChild(exButton);
|
||||
exButton.addEventListener('click', () => document.querySelectorAll('.expando-button.collapsed').forEach(e => e.click()));
|
||||
|
||||
let deButton = document.createElement('button');
|
||||
deButton.innerText = 'Collapse images';
|
||||
deButton.innerText = 'Collapse';
|
||||
deButton = para.appendChild(deButton);
|
||||
deButton.addEventListener('click', () => document.querySelectorAll('.expando-button.expanded').forEach(e => e.click()));
|
||||
|
||||
para = listing.insertBefore(para, listing.firstChild);
|
||||
|
||||
const proxyThumbClicks = function(evt) {
|
||||
let thing = evt.target;
|
||||
while (!thing.classList.contains('thing') && thing != document.body) {
|
||||
|
|
@ -40,10 +42,5 @@
|
|||
return false;
|
||||
};
|
||||
|
||||
let icoButton = document.createElement('button');
|
||||
icoButton.innerText = 'Thumb expands';
|
||||
icoButton = para.appendChild(icoButton);
|
||||
icoButton.addEventListener('click', () => listing.querySelectorAll('.thumbnail').forEach(e => e.addEventListener('click', proxyThumbClicks)));
|
||||
|
||||
para = listing.insertBefore(para, listing.firstChild);
|
||||
listing.querySelectorAll('.thumbnail').forEach(e => e.addEventListener('click', proxyThumbClicks));
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue