simplify icon indicating copy to clipboard operation
simplify copied to clipboard

Hide pagination controls in list view unless there are more than 100 items on the screen

Open leggett opened this issue 7 years ago • 3 comments

Add a mutation observer for the total number of items on the screen: document.querySelectorAll('div[gh="tm"] .Dj .ts')[2]

If this number is under 100, we should be able to assume that no pagination is needed and we can totally hide the pagination controls. If it is above 100, we need to show it. This will mean you don't know how many items are in the view, but that seems like a small sacrifice.

leggett avatar Apr 17 '19 17:04 leggett

Another approach is to look at whether the pagination buttons (< and >) are clickable. If both are grayed out, then the controls can be hidden, whereas if one or more are clickable then it should be shown. Benefits of this approach are it should work regardless of how many conversations per page the user has selected, and it hides pagination controls in message view if they aren't clickable.

Here's a working example (tested in Firefox):

function hidePageCtrl(changes, observer) {
	// Iterate over control divs
	// .ar5 in list view; .iG in single message view
	var ctrl_divs = document.querySelectorAll('div.ar5, div.iG');
	ctrl_divs.forEach(function(ctrl) {
		if (!ctrl.hidden) { // make sure it is visible; no point re-trying if we already hid it
			// Count the number of unclickable buttons
			var btns = ctrl.querySelectorAll('.T-I-JE');
			// Hide ctrl if 2 unclickable buttons are counted
			if (btns.length == 2) {
				ctrl.style.display = "none";
			}
		}
	});
}
(new MutationObserver(hidePageCtrl)).observe(document, {childList: true, subtree: true});```

sweinreich avatar Apr 17 '19 18:04 sweinreich

Cool idea. It might break if the .T-I-JE classname used to gray out disable things changes. That is a risk with my approach too but I find the higher level classnames change less often than the lower level ones.

Another way to do it might be to look for aria-disabled="true" within the right scope.

leggett avatar Apr 17 '19 19:04 leggett

Ok, built this out as part of v1.2.0. Just submitted to the Chrome Web Store.

leggett avatar Apr 18 '19 17:04 leggett