Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: files/css.js

Issue 8493027: Acquired Opera AdBlock code (Closed)
Patch Set: Created Oct. 8, 2012, 5:58 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « files/button.js ('k') | files/default.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: files/css.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/files/css.js
@@ -0,0 +1,53 @@
+const css = {
+ get: function(key) {
+ return preferences.array(key + '-content');
+ },
+ personal: function() {
+ return preferences.array('css-perso-content');
+ },
+ refresh: function() {
+ var success = true;
+ for(key in sources.css) {
+ if(preferences.bool(key)){ //If the list is enabled, update it
+ if(!this.update(key)) //In case of error with the update
+ success = false;
+ }
+ else //If the list is disabled, remove it
+ this.disable(key, false);
+ }
+ //opera.extension.postMessage({request: 'ping', type: 'css'}); //Make all webpages update
+ return success;
+ },
+ time: function(key) {
+ return preferences.int(key + '-time');
+ },
+ update: function(key) {
+ //opera.postError('Update called for ' + key);
+ var value = download(sources.css[key]).replace(/\/\*(.|\n)*?\*\/(\n)?/gm, '').split('\n');
+ //opera.postError(value.join("\n"));
+ if(value instanceof Array) {
+ preferences.array(key + '-content', value);
+ preferences.int(key + '-time', getTime());
+ return true;
+ }
+ else
+ return false;
+ },
+ status: function(key) {
+ return preferences.bool(key);
+ },
+ disable: function(key, ping) { //Disables a source
+ preferences.remove(key + '-time');
+ preferences.remove(key + '-content');
+ preferences.bool(key, false);
+ if(ping)
+ opera.extension.postMessage({request: 'ping', type: 'css'});
+ return true;
+ },
+ enable: function(key, ping) { //Enables a source
+ this.update(key);
+ preferences.bool(key, true);
+ if(ping)
+ opera.extension.postMessage({request: 'ping', type: 'css'});
+ }
+};
« no previous file with comments | « files/button.js ('k') | files/default.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld