gavin19

RES - Self-post Filter

Sep 23rd, 2011
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modules['selfPostFilter'] = {
  2.     moduleID: 'selfPostFilter',
  3.     moduleName: 'Self Post Filter',
  4.     options: {
  5.         //
  6.     },
  7.     description: 'Self-post filter',
  8.     isEnabled: function() {
  9.         return RESConsole.getModulePrefs(this.moduleID);
  10.     },
  11.     include: Array(
  12.         /reddit.com/i
  13.     ),
  14.     exclude: new Array(
  15.         /^https?:\/\/www\.reddit\.com\/prefs\//i,
  16.         /^https?:\/\/www\.reddit\.com\/message\//i,
  17.         /^https?:\/\/www\.reddit\.com\/user\//i
  18.     ),
  19.     isMatchURL: function() {
  20.         return RESUtils.isMatchURL(this.moduleID);
  21.     },
  22.     go: function() {
  23.         if ((this.isEnabled()) && (this.isMatchURL())) {
  24.         var parentDiv = document.querySelectorAll('div.sidebox.submit div.morelink')[0];
  25.         var dv = document.createElement("div");
  26.         dv.setAttribute("id", "selfPostDiv");
  27.         dv.innerHTML = "<p><input type='checkbox' defaultChecked='false' id='selfCB'> Self Post Filter ON/OFF</p><br/>";
  28.         parentDiv.parentNode.insertBefore(dv, parentDiv);
  29.         document.getElementById('selfCB').addEventListener('click', function() {
  30.             if (selfCB.checked == false) {
  31.             var i = document.querySelectorAll('div.thing.link');
  32.             for (var x = 0,leni=i.length; x <= leni-1; x++) {
  33.                 i[x].setAttribute('style', 'display:block');
  34.             }
  35.             } else {
  36.             var i = document.querySelectorAll('div.thing.link:not(.self)');
  37.             for (var j = 0,lenj=i.length; j <= lenj-1; j++) {
  38.                 i[j].setAttribute('style', 'display:none');
  39.             }
  40.             }
  41.         });
  42.         }
  43.     }
  44. };
Add Comment
Please, Sign In to add comment