Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modules['voteThreshold'] = {
- moduleID: 'voteThreshold',
- moduleName: 'Vote Threshold',
- category: 'Filters',
- options: {
- threshold: {
- type: 'text',
- value: '-10',
- description: 'Posts with less than the specified (negative) value will be hidden'
- }
- },
- description: 'Filter subreddit posts which fall below the specified threshold.',
- isEnabled: function () {
- return RESConsole.getModulePrefs(this.moduleID);
- },
- include: Array(/https?:\/\/([a-z]+).reddit.com\/?(?:\??[\w]+=[\w]+&?)*/i),
- exclude: Array(/https?:\/\/([a-z]+).reddit.com\/r\/[-\w\.]+/i, /https?:\/\/([a-z]+).reddit.com\/[-\w\.\/]+\/comments\/[-\w\.]+/i, /https?:\/\/([a-z]+).reddit.com\/user\/[-\w\.]+/i, /https?:\/\/([a-z]+).reddit.com\/message\/[-\w\.]+/i),
- isMatchURL: function () {
- return RESUtils.isMatchURL(this.moduleID);
- },
- applyThresholdFilter: function (ele) {
- var votes,
- thisPost,
- thisVW,
- vwThreshold = this.options.threshold.value;
- for (var i=0, len=ele.length; i < len; i+=1) {
- thisPost = ele[i];
- if(thisPost.innerHTML && thisPost.innerHTML.match(/\-/)){
- thisVW = thisPost.innerHTML.replace(/\[|\]/g,'');
- if(thisVW>vwThreshold) {
- thisPost.parentNode.parentNode.parentNode.setAttribute('style','opacity:0.3');
- }
- }
- }
- },
- go: function () {
- if ((this.isEnabled()) && (this.isMatchURL())) {
- document.body.addEventListener('DOMNodeInserted', function (event) {
- if ((event.target.tagName == 'DIV') && (event.target.getAttribute('id') && event.target.getAttribute('id').indexOf('siteTable') != -1)) {
- var ele = event.target.querySelectorAll('.thing .voteWeight');
- modules['voteThreshold'].applyThresholdFilter(ele);
- }
- }, false);
- setTimeout(function(){var ele = document.querySelectorAll('.sitetable .thing .voteWeight');
- modules['voteThreshold'].applyThresholdFilter(ele);},3000);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement