Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add last update info

minor optimization Block external scripts
  • Loading branch information...
commit b2e874211a1cc7175601925747ccd21452d3bb73 1 parent fa4ae40
@Gemorroj authored
View
33 includes/noads-options.js
@@ -248,6 +248,21 @@ var options = {
tmp = null;
return retRe ? new RegExp((rez.join('|').replace(/\/|\.(?=[\w\d])/g, '\\$&') || '^$'), 'i') : true;
},
+ getLastUpdate: function () {
+ var lastUpdate = getValue('noads_last_update');
+ if (lastUpdate) {
+ var d = new Date(Number(lastUpdate));
+ return d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
+ }
+ return '';
+ },
+ setLastUpdate: function (node) {
+ var lastUpdate = this.getLastUpdate();
+ if (lastUpdate) {
+ var lng = TRANSLATE();
+ node.nodeValue = lng.lUpdate + ' ' + lastUpdate;
+ }
+ },
showPreferences: function (domain) {
if (!document.body) return;
var global = domain ? false : true;
@@ -296,7 +311,7 @@ var options = {
if (!global) win.style.marginTop = '4%';
overlay.appendChild(win);
var img = document.createElement('div');
- img.className = 'noads_close_window'
+ img.className = 'noads_close_window';
img.title = lng.pClose;
img.onclick = function () {
if (global) {
@@ -410,7 +425,7 @@ var options = {
};
area.createRadioButton = function (txt, url, typein) {
var label = document.createElement('label');
- label.className = 'noads_label_subscription'
+ label.className = 'noads_label_subscription';
var input = document.createElement('input');
input.type = 'checkbox';
input.name = 'subs';
@@ -661,13 +676,15 @@ var options = {
this.createRadioButton('FanBoy swedish', 'http://www.fanboy.co.nz/adblock/opera/swe/urlfilter.ini');
this.appendChild(document.createElement('br'));
this.createRadioButton(' (*.txt, *.ini)', getValue('noads_custom_url'), true);
-
+
this.appendChild(this.createCheckbox('noads_allrules', lng.pAllRules, 'right positive', '', 'right negative unchecked'));
+ var lastUpdatedNode = document.createTextNode('');
+
this.appendChild(this.createButton('noads_dlsubscription', lng.pDownload, function () {
var dlsubscription = document.getElementById('noads_dlsubscription');
if (dlsubscription.disabled === true) return; else dlsubscription.disabled = true;
-
+
var url = [], inputs = area.getElementsByTagName('input');
for (var i = 0, radioButton; radioButton = inputs[i]; i++) {
if (radioButton.type === 'checkbox' && radioButton.checked) { url.push(radioButton.nextElementSibling.href || radioButton.nextElementSibling.value); }
@@ -675,9 +692,17 @@ var options = {
if (url.length) {
dlsubscription.childNodes[0].src = imgLoad;
setValue('noads_default_url2', url);
+ setValue('noads_last_update', new Date().getTime());
+
postMsg({ type: 'get_filters', url: url, allRules: document.getElementById('noads_allrules_toggle').getAttribute('checked') == 'true' });
+
+ options.setLastUpdate(lastUpdatedNode);
} else postMsg({ type: 'get_filters', url: '' });
}, '', imgRefresh));
+
+ this.appendChild(document.createElement('br'));
+ this.appendChild(lastUpdatedNode);
+ options.setLastUpdate(lastUpdatedNode);
};
area.showHelp = function (pos) {
this.clear(pos);
View
52 includes/noads-translation.js
@@ -25,7 +25,7 @@ var OPERA_VERSION = window.opera.version();
var TRANSLATE = function () {
switch (window.navigator.language) {
case 'ru': return {
- _s: function (count) { return (count > 4) ? '\u043e\u0432' : ((count > 1) ? '\u0430' : '') },
+ _s: function (count) { return (count > 4) ? '\u043e\u0432' : ((count > 1) ? '\u0430' : ''); },
unblock: '\u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c: ',
disabled: '\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e',
blocked: '\u0417\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e',
@@ -77,10 +77,11 @@ var TRANSLATE = function () {
pToolbarButton: '\u041a\u043d\u043e\u043f\u043a\u0430 \u043d\u0430 \u0442\u0443\u043b\u0431\u0430\u0440\u0435',
pCSSlinks: '\u0421\u0441\u044b\u043b\u043a\u0438, \u0432\u043d\u0435\u0434\u0440\u0451\u043d\u043d\u044b\u0435 \u0432 CSS',
pDebug: '\u041e\u0442\u043b\u0430\u0434\u043a\u0430',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'tr': return {
- _s: function (count) { return (count > 1) ? 's' : '' },
+ _s: function (count) { return (count > 1) ? 's' : ''; },
unblock: 'Serbest b\u0131rak: ',
disabled: 'Engelleme durduruldu',
blocked: 'Engellendi',
@@ -132,10 +133,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'fr': return {
- _s: function (count) { return (count > 1) ? 's' : '' },
+ _s: function (count) { return (count > 1) ? 's' : ''; },
unblock: 'Debloquer : ',
disabled: 'Blocage desactive',
blocked: 'Bloque',
@@ -187,10 +189,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'pl': return {
- _s: function (count) { return (count > 4) ? '\u00f3w' : ((count > 1) ? 'y' : '') },
+ _s: function (count) { return (count > 4) ? '\u00f3w' : ((count > 1) ? 'y' : ''); },
unblock: 'Odblokuj',
disabled: 'Blokowanie jest wy\u0142\u0105czone',
blocked: 'Zablokowano',
@@ -242,10 +245,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Przycisk na pasku',
pCSSlinks: 'Linki osadzone w CSS',
pDebug: 'Debuguj',
- pInvalidSelector: 'Selektor CSS jest niepoprawny. Prosz\u0119 sprawdzi\u0107 sk\u0142adni\u0119.'
+ pInvalidSelector: 'Selektor CSS jest niepoprawny. Prosz\u0119 sprawdzi\u0107 sk\u0142adni\u0119.',
+ lUpdate: 'Last update:'
};
case 'zh-tw': return {
- _s: function (count) { return (count > 1) ? '' : '' },
+ _s: function (count) { return (count > 1) ? '' : ''; },
unblock: '\u53D6\u6D88\u963B\u64CB: ',
disabled: '\u505C\u6B62\u963B\u64CB',
blocked: '\u5DF2\u963B\u64CB',
@@ -297,10 +301,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'zh_TW': return {
- _s: function (count) { return (count > 1) ? '' : '' },
+ _s: function (count) { return (count > 1) ? '' : ''; },
unblock: '\u53D6\u6D88\u963B\u64CB: ',
disabled: '\u505C\u6B62\u963B\u64CB',
blocked: '\u5DF2\u963B\u64CB',
@@ -352,10 +357,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'zh-cn': return {
- _s: function (count) { return (count > 1) ? '' : '' },
+ _s: function (count) { return (count > 1) ? '' : ''; },
unblock: '\u53D6\u6D88\u963B\u6321: ',
disabled: '\u505C\u6B62\u963B\u6321',
blocked: '\u5DF2\u963B\u6321',
@@ -407,10 +413,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'zh_CN': return {
- _s: function (count) { return (count > 1) ? '' : '' },
+ _s: function (count) { return (count > 1) ? '' : ''; },
unblock: '\u53D6\u6D88\u963B\u6321: ',
disabled: '\u505C\u6B62\u963B\u6321',
blocked: '\u5DF2\u963B\u6321',
@@ -462,10 +469,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
case 'de': return {
- _s: function (count) { return (count > 1) ? 'e' : '' },
+ _s: function (count) { return (count > 1) ? 'e' : ''; },
unblock: 'Deblockiere: ',
disabled: 'Blockierung deaktiviert',
blocked: 'Blockiert',
@@ -517,10 +525,11 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
};
default: return {
- _s: function (count) { return (count > 1) ? 's' : '' },
+ _s: function (count) { return (count > 1) ? 's' : ''; },
unblock: 'Unblock',
disabled: 'Blocking disabled',
blocked: 'Blocked',
@@ -534,7 +543,7 @@ var TRANSLATE = function () {
bElement: 'Input CSS selector(s) of element(s) to block (= euqals, ^= begins with; *= contains):',
iSubs: 'Subscription from %url added %d rules.',
iNoDefSub: 'Error: no default subscription.',
- iNoQuota: 'Opera '+OPERA_VERSION+' does not support widget.preferences or storage quota is too small. \n\nSet "opera:config#WebStorage|GlobalQuotaForWidgetPreferences" >= 2048.',
+ iNoQuota: 'Opera ' + OPERA_VERSION + ' does not support widget.preferences or storage quota is too small. \n\nSet "opera:config#WebStorage|GlobalQuotaForWidgetPreferences" >= 2048.',
pInfo: 'Information',
pError: 'Error',
pClose: 'Close',
@@ -572,7 +581,8 @@ var TRANSLATE = function () {
pToolbarButton: 'Toolbar button',
pCSSlinks: 'Links embedded in CSS',
pDebug: 'Debug',
- pInvalidSelector: 'CSS selector is invalid. Please check the syntax.'
+ pInvalidSelector: 'CSS selector is invalid. Please check the syntax.',
+ lUpdate: 'Last update:'
}
}
}; //TRANSLATION
View
12 includes/noads.js
@@ -84,10 +84,9 @@ var bDebug = options.checkEnabled('noads_debug_enabled_state'), sStyle, uStyle,
// Enumerate backgrounds for helper
window.opera.addEventListener('BeforeCSS', function (userJSEvent) {
//alert(userJSEvent);
- var append = function (str, p1, offset, s) {
+ userJSEvent.cssText.replace(/(?:url\(['"]?)([^'"\)]+)(?:['"]?\))/ig, function (str, p1, offset, s) {
bgImages += p1 + '; ';
- };
- userJSEvent.cssText.replace(/(?:url\(['"]?)([^'"\)]+)(?:['"]?\))/ig, append);
+ });
}, false);
// Block external scripts
@@ -100,7 +99,7 @@ var bDebug = options.checkEnabled('noads_debug_enabled_state'), sStyle, uStyle,
if (!src || reSkip.test(src) || e.element.isNoAdsSubscription) return;
var site = window.location.hostname, full = !/\.(com|[a-z]{2})$/i.test(site);
var a = src.match(/^https?:\/\/([^\/]+@)?([^:\/]+)/i);
- if (getTLD(a ? a[2] : site, full) != getTLD(site, full)) {
+ if (a && getTLD(a[2], full) != getTLD(site, full)) {
e.preventDefault();
if (blockedScripts.indexOf(src) == -1) blockedScripts += blockedScripts ? '; ' + src : src;
log('blocked script -> ' + src + ' for <' + site + '>');
@@ -122,7 +121,7 @@ var bDebug = options.checkEnabled('noads_debug_enabled_state'), sStyle, uStyle,
var showButton = function (e) {
var docEle;
- if (document && document.compatMode == 'CSS1Compat' && window.postMessage) docEle = document.documentElement;
+ if (document && document.compatMode === 'CSS1Compat' && window.postMessage) docEle = document.documentElement;
else docEle = document.body;
if (docEle && docEle.clientHeight - e.clientY < 20 && docEle.clientWidth - e.clientX < 70) {
run.createButton(sCSS ? (uCSS ? sCSS + ',' + uCSS : sCSS) : uCSS, inlineScripts ? ('<script>(' + inlineScripts + ')' + (blockedScripts ? '; ' + blockedScripts : '')) : blockedScripts);
@@ -146,7 +145,6 @@ var bDebug = options.checkEnabled('noads_debug_enabled_state'), sStyle, uStyle,
// Create the quick button
if (window.top === window.self) { // don't want that in a frames
- //window.removeEventListener('mousemove', showButton, false);
if (options.checkEnabled('noads_button_state')) {
log('button is enabled...');
addStyle(quickButtonCSS, 'qbCSS');
@@ -196,7 +194,7 @@ var bDebug = options.checkEnabled('noads_debug_enabled_state'), sStyle, uStyle,
// Create menu messaging channel and parse background messages
opera.extension.onmessage = function (e) {
var message = decodeMessage(e.data);
- if (message.type == 'noads_bg_port') {
+ if (message.type === 'noads_bg_port') {
var channel = new MessageChannel();
//background = e.source;
e.ports[0].postMessage(encodeMessage({
View
2  index.html
@@ -134,7 +134,7 @@
realoadRules(true, true);
if (!addRules && arrayFilters.length) {
arrayFilters = null;
- arrayFilters = new Array();
+ arrayFilters = [];
}
for (var i = 0, entries = arraySubscription.length; i < entries; i++) {
View
8 scripts/noads-importer.js
@@ -1,7 +1,6 @@
-
var importer = {
// import subscription to a local storage
- getHidingRulesLength: function(arr){
+ getHidingRulesLength: function (arr) {
var rule, pos, len = 0;
for (var i = 0; i < arr.length; i++) {
rule = arr[i];
@@ -11,7 +10,8 @@ var importer = {
}
return len;
},
- importSubscription: function(list, url, allRules, addRules){
+
+ importSubscription: function (list, url, allRules, addRules) {
var convertOldRules = function(tagName, attrRules){
var rule, rules, sep, additional = '', id = null, reAttrRules = /\([\w\-]+(?:[$^*]?=[^\(\)"]*)?\)/g;
if (tagName == '*') tagName = '';
@@ -81,7 +81,7 @@ var importer = {
};
var filterRulesList;
- if (!addRules) { filterRulesList = getHidingRules(list, allRules) }
+ if (!addRules) { filterRulesList = getHidingRules(list, allRules); }
else {
filterRulesList = getValue('noads_list').split('\n').concat(getHidingRules(list, allRules));
filterRulesList = unique.call(filterRulesList);
Please sign in to comment.
Something went wrong with that request. Please try again.