// ==UserScript==
// @include *
// @run-at document-start
// ==/UserScript==

/*
 * Gmail-Basic-HTML-Select-All
 *
 * Add a "check all" button in HTML-Gmail's spam and trash folders.
 *
 * By kafene software <http://kafene.org/>
 */
window.addEventListener("DOMContentLoaded", function () {
    if (/^mail\.google\./i.test(window.location.host)) {
        return;
    }

    var del = document.querySelector('input[type="submit"][value="Delete Forever"]');
    if (!del) {
        return;
    }

    var cbox = document.createElement('input');
    cbox.setAttribute('type', 'checkbox');

    cbox.addEventListener('click', function () {
        var boxes = document.querySelectorAll('input[type="checkbox"]');

        [].forEach.call(boxes, function (box) {
            if (box == cbox) { return; }
            if (box.checked) {
                box.removeAttribute('checked');
            } else {
                box.setAttribute('checked', true);
            }
        });

    });

    del.parentNode.insertBefore(cbox, del);
});

@@ -292,16 +292,17 @@
     if (
+!
 /%5Email%5C.
@@ -463,13 +463,32 @@
 if (
-!
+'object' != typeof(
 del)
+)
  %7B%0A 
@@ -802,24 +802,40 @@
  cbox) %7B
+%0A               
  return;
  %7D%0A     
@@ -826,19 +826,18 @@
  return;
- %7D
 %0A
+ 
         
@@ -831,32 +831,38 @@
 rn;%0A            
+%7D else
  if (box.checked

Fix missing negation / site detection