diff --git a/ESGST.meta.js b/ESGST.meta.js index d5812247..e909d343 100644 --- a/ESGST.meta.js +++ b/ESGST.meta.js @@ -1,3 +1,3 @@ // ==UserScript== -// @version 6.Beta.38.4 +// @version 6.Beta.38.5 // ==/UserScript== diff --git a/ESGST.user.js b/ESGST.user.js index 9e8a2960..629d756f 100644 --- a/ESGST.user.js +++ b/ESGST.user.js @@ -3,7 +3,7 @@ // @namespace ESGST // @description Enhances SteamGifts and SteamTrades by adding some cool features to them. // @icon https://dl.dropboxusercontent.com/s/lr3t3bxrxfxylqe/esgstIcon.ico?raw=1 -// @version 6.Beta.38.4 +// @version 6.Beta.38.5 // @author revilheart // @downloadURL https://github.com/revilheart/ESGST/raw/master/ESGST.user.js // @updateURL https://github.com/revilheart/ESGST/raw/master/ESGST.meta.js @@ -56,7 +56,7 @@ this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:fun !function(t,r){e.exports=r()}(this,function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function i(e){return"function"==typeof e}function s(e){V=e}function o(e){K=e}function u(){return function(){return t.nextTick(l)}}function a(){return"undefined"!=typeof $?function(){$(l)}:h()}function c(){var e=0,t=new Z(l),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function p(){var e=new MessageChannel;return e.port1.onmessage=l,function(){return e.port2.postMessage(0)}}function h(){var e=setTimeout;return function(){return e(l,1)}}function l(){for(var e=0;e=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],s=this._serializer||v.serialize[i?i.split(";")[0]:""];!s&&a(i)&&(s=v.serialize["application/json"]),s&&(r=s(r))}for(var o in this.header)null!=this.header[o]&&this.header.hasOwnProperty(o)&&t.setRequestHeader(o,this.header[o]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send("undefined"!=typeof r?r:null),this},v.get=function(e,t,r){var n=v("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},v.head=function(e,t,r){var n=v("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},v.options=function(e,t,r){var n=v("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},v.del=h,v.delete=h,v.patch=function(e,t,r){var n=v("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},v.post=function(e,t,r){var n=v("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},v.put=function(e,t,r){var n=v("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},function(e,t){function r(e){return"https://"+e+".dropboxapi.com/2/"}e.exports=r},function(e,t){function r(e){return null!==e&&"object"==typeof e}e.exports=r},function(e,t){function r(e){return JSON.stringify(e).replace(n,function(e){return"\\u"+("000"+e.charCodeAt(0).toString(16)).slice(-4)})}var n=/[\u007f-\uffff]/g;e.exports=r},function(e,t,r){var n,i=r(16);r(15),n=function(e){e=e||{},this.accessToken=e.accessToken,this.clientId=e.clientId,this.selectUser=e.selectUser},n.prototype.setAccessToken=function(e){this.accessToken=e},n.prototype.getAccessToken=function(){return this.accessToken},n.prototype.setClientId=function(e){this.clientId=e},n.prototype.getClientId=function(){return this.clientId},n.prototype.getAuthenticationUrl=function(e,t){var r,n="https://www.dropbox.com/oauth2/authorize",i=this.getClientId();if(!i)throw new Error("A client id is required. You can set the client id using .setClientId().");if(!e)throw new Error("A redirect uri is required.");return r=n+"?response_type=token&client_id="+i,e&&(r=r+"&redirect_uri="+e),t&&(r=r+"&state="+t),r},n.prototype.authenticateWithCordova=function(e,t){var r="https://www.dropbox.com/1/oauth2/redirect_receiver",n=this.getAuthenticationUrl(r),i=window.open(n,"_blank"),s=!1,o=function(e){window.setTimeout(function(){i.close()},10),t()},u=function(r){var n="&error=",s=r.url.indexOf(n);if(s>-1)window.setTimeout(function(){i.close()},10),t();else{var o="#access_token=",u=r.url.indexOf(o),a=r.url.indexOf("&token_type=");if(u>-1){u+=o.length,window.setTimeout(function(){i.close()},10);var c=r.url.substring(u,a);e(c)}}},a=function(e){s||(i.removeEventListener("loaderror",o),i.removeEventListener("loadstop",u),i.removeEventListener("exit",a),s=!0)};i.addEventListener("loaderror",o),i.addEventListener("loadstop",u),i.addEventListener("exit",a)},n.prototype.request=function(e,t,r,n,s){var o=null;switch(s){case i.RPC:o=this.getRpcRequest();break;case i.DOWNLOAD:o=this.getDownloadRequest();break;case i.UPLOAD:o=this.getUploadRequest();break;default:throw new Error("Invalid request style: "+s)}return o(e,t,r,n,this.getAccessToken(),this.selectUser)},n.prototype.setRpcRequest=function(e){n.prototype.rpcRequest=e},n.prototype.getRpcRequest=function(){return void 0===n.prototype.rpcRequest&&(n.prototype.rpcRequest=r(18)),n.prototype.rpcRequest},n.prototype.setDownloadRequest=function(e){n.prototype.downloadRequest=e},n.prototype.getDownloadRequest=function(){return void 0===n.prototype.downloadRequest&&(n.prototype.downloadRequest=r(13)),n.prototype.downloadRequest},n.prototype.setUploadRequest=function(e){n.prototype.uploadRequest=e},n.prototype.getUploadRequest=function(){return void 0===n.prototype.uploadRequest&&(n.prototype.uploadRequest=r(19)),n.prototype.uploadRequest},e.exports=n},function(e,t,r){function n(e){if(e)return i(e)}function i(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n,i=0;i1)for(var r=1;r=200&&e.status<300)},n.prototype.get=function(e){return this._header[e.toLowerCase()]},n.prototype.getHeader=n.prototype.get,n.prototype.set=function(e,t){if(s(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},n.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},n.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),s(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var n in t)this.field(e,t[n]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},n.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},n.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},n.prototype.redirects=function(e){return this._maxRedirects=e,this},n.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},n.prototype.send=function(e){var t=s(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&s(this._data))for(var n in e)this._data[n]=e[n];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+e:e:this._data=(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},n.prototype.sortQuery=function(e){return this._sort="undefined"==typeof e||e,this},n.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},n.prototype._appendQueryString=function(){console.trace("Unsupported")},n.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},n.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},function(e,t,r){function n(e){if(e)return i(e)}function i(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}var s=r(12);e.exports=n,n.prototype.get=function(e){return this.header[e.toLowerCase()]},n.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=s.type(t);var r=s.params(t);for(var n in r)this[n]=r[n];this.links={};try{e.link&&(this.links=s.parseLinks(e.link))}catch(e){}},n.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e}},function(e,t){var r=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];e.exports=function(e,t){return!!(e&&e.code&&~r.indexOf(e.code))||(!!(t&&t.status&&t.status>=500)||(!!(e&&"timeout"in e&&"ECONNABORTED"==e.code)||!!(e&&"crossDomain"in e)))}},function(e,t){t.type=function(e){return e.split(/ *; */).shift()},t.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e},{})},t.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1),i=r[1].split(/ *= */)[1].slice(1,-1);return e[i]=n,e},{})},t.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&delete e.cookie,e}},function(e,t,r){var n,i,s,o=r(2),u=r(1).Promise,a=r(3),c=r(5);o.parse["application/octect-stream"]=function(e){return e},n=function(e,t){return{status:e.status,error:(t?t.text:null)||e.toString(),response:t}},s=function(e,t){e.text="",e.setEncoding("binary"),e.on("data",function(t){e.text+=t}),e.on("end",function(){t()})},i=function(e,t,r,i,p,h){if("user"!==r)throw new Error("Unexpected auth type: "+r);var l=function(r,u){function l(e){r&&r(e)}function f(e){u&&u(e)}function d(e,t){var r;e?f(n(e,t)):(r=JSON.parse(t.headers["dropbox-api-result"]),t.xhr?r.fileBlob=t.xhr.response:r.fileBinary=t.res.text,l(r))}var _;_=o.post(a(i)+e).set("Authorization","Bearer "+p).set("Dropbox-API-Arg",c(t)).on("request",function(){this.xhr&&(this.xhr.responseType="blob")}),h&&(_=_.set("Dropbox-API-Select-User",h)),"undefined"==typeof window?_.buffer(!0).parse(s).end(d):_.end(d)};return new u(l)},e.exports=i},function(e,t,r){var n,i=r(6),s=r(17);n=function(e){i.call(this,e)},n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype=Object.assign(n.prototype,s),n.prototype.filesGetSharedLinkFile=function(e){return this.request("sharing/get_shared_link_file",e,"api","download")},e.exports=n},function(e,t){"function"!=typeof Object.assign&&!function(){Object.assign=function(e){"use strict";var t,r,n,i;if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(t=Object(e),r=1;r -
  • Currently filters "good luck", "have fun" and "enjoy" variations. The filter might not be perfect. If you see any description format that you think is useless, feel free to report it in the ESGST discussion and I'll add it to the filter.
  • - - `, + id: `elgb_c`, + name: `[NEW] Cache repeated descriptions from the same creator for 1 hour and only show them once.`, + sg: true + }, + { id: `elgb_f`, + input: true, name: `[NEW] Filter out useless descriptions.`, sg: true }, @@ -8663,7 +8665,7 @@ this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:fun addGfUnhideButton(giveaway, main); } } - if ((source !== `gc` && esgst.giveawaysPath) || esgst.giveawayPath) { + if ((source !== `gc` && (esgst.giveawaysPath || esgst.groupPath)) || esgst.giveawayPath) { if (!giveaway.innerWrap.getElementsByClassName(`esgst-gf-hide-button`)[0] && (!savedGiveaways[giveaway.code] || !savedGiveaways[giveaway.code].hidden || !savedGiveaways[giveaway.code].code)) { addGfHideButton(giveaway, main); } @@ -10892,29 +10894,36 @@ ${avatar.outerHTML} } description = DOM.parse(response.responseText).getElementsByClassName(`page__description`)[0]; if (description && !mainCallback) { - if (Date.now() - esgst.elgbCache.timestamp > 3600000) { - esgst.elgbCache = { - descriptions: {}, - timestamp: Date.now() - }; - setValue(`esgst_elgbCache`, JSON.stringify(esgst.elgbCache)); - } - if (!esgst.elgbCache.descriptions[giveaway.creator]) { - esgst.elgbCache.descriptions[giveaway.creator] = []; - } - let html = description.innerHTML, i; - for (i = esgst.elgbCache.descriptions[giveaway.creator].length - 1; i > -1 && esgst.elgbCache.descriptions[giveaway.creator][i] !== html; --i); - if (i > -1) { - description = null; - } else { - esgst.elgbCache.descriptions[giveaway.creator].push(html); - setValue(`esgst_elgbCache`, JSON.stringify(esgst.elgbCache)); - if (esgst.elgb_f) { - let text = description.textContent.replace(/[^a-zA-Z]/g, ``).toLowerCase(); - if (text.match(/^(.|bestofluck|enjoy|gl|glhf|goodluck|havefun|havefunxd)$/)) { - description = null; + if (elgb_c) { + if (Date.now() - esgst.elgbCache.timestamp > 3600000) { + esgst.elgbCache = { + descriptions: {}, + timestamp: Date.now() + }; + setValue(`esgst_elgbCache`, JSON.stringify(esgst.elgbCache)); + } + if (!esgst.elgbCache.descriptions[giveaway.creator]) { + esgst.elgbCache.descriptions[giveaway.creator] = []; + } + let html = description.innerHTML, i; + for (i = esgst.elgbCache.descriptions[giveaway.creator].length - 1; i > -1 && esgst.elgbCache.descriptions[giveaway.creator][i] !== html; --i); + if (i > -1) { + description = null; + } else { + esgst.elgbCache.descriptions[giveaway.creator].push(html); + setValue(`esgst_elgbCache`, JSON.stringify(esgst.elgbCache)); + if (esgst.elgb_f) { + let text = description.textContent.replace(/[^a-zA-Z]/g, ``).toLowerCase(); + if (text.match(new RegExp(`^(${esgst.elgb_filters})$`))) { + description = null; + } } } + } else if (esgst.elgb_f) { + let text = description.textContent.replace(/[^a-zA-Z]/g, ``).toLowerCase(); + if (text.match(new RegExp(`^(${esgst.elgb_filters})$`))) { + description = null; + } } } if (description) { @@ -10937,6 +10946,13 @@ ${avatar.outerHTML} if (mainCallback) { popup.onClose = mainCallback; } + set = new ButtonSet(`grey`, `grey`, `fa-eye`, `fa-circle-o-notch fa-spin`, `Add Description To Filters`, `Filtering...`, function (callback) { + esgst.elgb_filters = `${esgst.elgb_filters}|${description.textContent.replace(/[^a-zA-Z]/g, ``).toLowerCase()}`; + setValue(`elgb_filters`, esgst.elgb_filters); + callback(); + set.remove(); + }).set; + popup.description.appendChild(set); popup.open(function () { box.focus(); }); @@ -10944,6 +10960,13 @@ ${avatar.outerHTML} if (mainCallback) { popup.onClose = mainCallback; } + set = new ButtonSet(`grey`, `grey`, `fa-eye`, `fa-circle-o-notch fa-spin`, `Add Description To Filters`, `Filtering...`, function (callback) { + esgst.elgb_filters = `${esgst.elgb_filters}|${description.textContent.replace(/[^a-zA-Z]/g, ``).toLowerCase()}`; + setValue(`elgb_filters`, esgst.elgb_filters); + callback(); + set.remove(); + }).set; + popup.description.appendChild(set); popup.open(); } } else if ((esgst.elgb_r && !esgst.elgb_r_d) || mainCallback) { @@ -30694,6 +30717,16 @@ ${avatar.outerHTML} setSetting(`hr_minutes`, input.firstElementChild.value); esgst.hr_minutes = input.firstElementChild.value; }); + } else if (Feature.id === `elgb_f`) { + input = insertHtml(SMFeatures, `beforeEnd`, ` +
    + Filters: +
    + `); + input.firstElementChild.addEventListener(`change`, function() { + setSetting(`elgb_filters`, input.firstElementChild.value); + esgst.elgb_filters = input.firstElementChild.value; + }); } if (siwtchSg) { siwtchSg.dependencies.push(SMFeatures); @@ -31798,7 +31831,7 @@ ${avatar.outerHTML} } if (esgst.gf && esgst.gf_h && main) { var savedGiveaway = esgst.giveaways[giveaway.code]; - if (esgst.giveawaysPath && savedGiveaway && savedGiveaway.hidden && savedGiveaway.code) { + if ((esgst.giveawaysPath || esgst.groupPath) && savedGiveaway && savedGiveaway.hidden && savedGiveaway.code) { giveaway.outerWrap.remove(); return null; } @@ -31817,7 +31850,7 @@ ${avatar.outerHTML} giveaway.comments = parseInt(giveaway.commentsLink.textContent.replace(/,/g, ``).match(/\d+/)[0]); } giveaway.panel = giveaway.innerWrap.getElementsByClassName(`esgst-giveaway-panel`)[0]; - if (!giveaway.panel && (esgst.gwc || esgst.gwr || esgst.elgb || esgst.cewgd)) { + if (!giveaway.panel && (esgst.gwc || esgst.gwr || esgst.gp || esgst.elgb || esgst.cewgd)) { if (giveaway.links) { giveaway.panel = insertHtml(giveaway.links, `afterEnd`, `
    @@ -36452,6 +36485,18 @@ ${avatar.outerHTML} function loadChangelog(version) { var changelog, current, html, i, index, n, popup; changelog = [ + { + date: `October 4, 2017`, + version: `6.Beta.38.5`, + changelog: ` +
      +
    • Fixed a bug that was happening if Giveaway Popup was enabled, but Giveaway Winning Chance/Ratio, Enter/Leave Giveaway Button and Created/Entered/Won Giveaway Details were disabled.
    • +
    • Extended the option to hide individual giveaways to group pages.
    • +
    • Added an option to Enter/Leave Giveaway Button that allows repeated descriptions from the same creator to be cached for 1 hour and only shown once.
    • +
    • You can now add your own description filters to Enter/Leave Giveaway Button.
    • +
    + ` + }, { date: `October 2, 2017`, version: `6.Beta.38.4`, diff --git a/README.md b/README.md index 0286c048..f0a92bc0 100644 --- a/README.md +++ b/README.md @@ -852,6 +852,15 @@ The video above does not get embedded. ## Changelog +**6.Beta.38.5 (October 4, 2017):** + +
      +
    • Fixed a bug that was happening if Giveaway Popup was enabled, but Giveaway Winning Chance/Ratio, Enter/Leave Giveaway Button and Created/Entered/Won Giveaway Details were disabled.
    • +
    • Extended the option to hide individual giveaways to group pages.
    • +
    • Added an option to Enter/Leave Giveaway Button that allows repeated descriptions from the same creator to be cached for 1 hour and only shown once.
    • +
    • You can now add your own description filters to Enter/Leave Giveaway Button.
    • +
    + **6.Beta.38.4 (October 2, 2017):**