🔖 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
|
// @namespace danielrayjones
|
||||||
// @description Allow removal of visited links on Amazon Giveaway Listing
|
// @description Allow removal of visited links on Amazon Giveaway Listing
|
||||||
// @include https://old.reddit.com*
|
// @include https://old.reddit.com*
|
||||||
// @version 1.0.2
|
// @version 1.0.3
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -15,15 +15,17 @@
|
||||||
|
|
||||||
let para = document.createElement('p');
|
let para = document.createElement('p');
|
||||||
let exButton = document.createElement('button');
|
let exButton = document.createElement('button');
|
||||||
exButton.innerText = 'Expand images';
|
exButton.innerText = 'Expand';
|
||||||
exButton = para.appendChild(exButton);
|
exButton = para.appendChild(exButton);
|
||||||
exButton.addEventListener('click', () => document.querySelectorAll('.expando-button.collapsed').forEach(e => e.click()));
|
exButton.addEventListener('click', () => document.querySelectorAll('.expando-button.collapsed').forEach(e => e.click()));
|
||||||
|
|
||||||
let deButton = document.createElement('button');
|
let deButton = document.createElement('button');
|
||||||
deButton.innerText = 'Collapse images';
|
deButton.innerText = 'Collapse';
|
||||||
deButton = para.appendChild(deButton);
|
deButton = para.appendChild(deButton);
|
||||||
deButton.addEventListener('click', () => document.querySelectorAll('.expando-button.expanded').forEach(e => e.click()));
|
deButton.addEventListener('click', () => document.querySelectorAll('.expando-button.expanded').forEach(e => e.click()));
|
||||||
|
|
||||||
|
para = listing.insertBefore(para, listing.firstChild);
|
||||||
|
|
||||||
const proxyThumbClicks = function(evt) {
|
const proxyThumbClicks = function(evt) {
|
||||||
let thing = evt.target;
|
let thing = evt.target;
|
||||||
while (!thing.classList.contains('thing') && thing != document.body) {
|
while (!thing.classList.contains('thing') && thing != document.body) {
|
||||||
|
|
@ -40,10 +42,5 @@
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
let icoButton = document.createElement('button');
|
listing.querySelectorAll('.thumbnail').forEach(e => e.addEventListener('click', proxyThumbClicks));
|
||||||
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);
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue