Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 16 commits
  • 5 files changed
  • 0 comments
  • 2 contributors
96 includes/noads-options.js
@@ -12,8 +12,8 @@
12 12
13 13
14 14 // styles for option pages
15   -var optionsCSS = '.noads_overlay{visibility:visible;background-color:#e3e5e7;direction:ltr;display:block !important;font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;font-size:12px !important;height:100%;left:0;overflow:auto;position:fixed;top:0;width:100%;z-index:1000000 !important;margin:0;padding:0;}\
16   -.noads_win{letter-spacing:normal !important;box-sizing:content-box !important;text-transform:none !important;text-shadow:none !important;font-weight: normal !important;display:block !important;background-color:#f3f4f5;border-radius:0;color:#000;height:96.6%;overflow:visible;width:auto;margin:0 auto;padding:1%;}\
  15 +var optionsCSS = '.noads_overlay{visibility:visible;background-color:#e3e5e7;direction:ltr;display:block !important;font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;font-size:12px !important;left:0;overflow:auto;position:fixed;background-color:#f3f4f5;top:0;width:100%;z-index:1000000 !important;margin:0;padding:0;}\
  16 +.noads_win{letter-spacing:normal !important;box-sizing:content-box !important;text-transform:none !important;text-shadow:none !important;font-weight: normal !important;display:block !important;border-radius:0;color:#000;overflow:visible;width:auto;margin:50px;padding:1%;}\
17 17 .noads_close_window{letter-spacing:normal !important;text-transform:none !important;text-shadow:none !important;box-shadow:none !important;background:-o-skin("Caption Close Button Skin");border:none;cursor:pointer;display:block !important;float:right;height:18px;width:18px;margin:0;padding:0;}\
18 18 .noads_menu{letter-spacing:normal !important;text-transform:none !important;text-shadow:none !important;box-shadow:none !important;list-style:none;overflow:hidden;margin:0 0 -1px 2px;padding:2px 2px 0;}\
19 19 .noads_menu li{border:1px solid #aaa;border-bottom-color:#fafbfc;border-radius:4px 4px 0 0;color:#000;cursor:default;float:left;font-family:Tahoma,sans-serif;font-size:14px;line-height:normal;list-style-position:outside;text-align:left;white-space:nowrap;margin:0 0 0 1px;padding:3px 9px;}\
@@ -30,7 +30,7 @@ var optionsCSS = '.noads_overlay{visibility:visible;background-color:#e3e5e7;dir
30 30 .noads_content button.negative{color:#d12f19;}\
31 31 .noads_content button.negative:hover{background:#fbe3e4;border:1px solid #fbc2c4;color:#d12f19;}\
32 32 .noads_content p{letter-spacing:normal !important;text-transform:none !important;text-shadow:none !important;box-shadow:none !important;border-radius:0 !important;clear:both;text-align:left;padding-top:10px;margin:0;padding:0;}\
33   -.noads_area{height: 100%; letter-spacing:normal !important;text-transform:none !important;text-shadow:none !important;box-shadow:none !important;border-radius:0 !important;padding: 0 15px 0 15px; margin:0; width:auto;}\
  33 +.noads_area{/*height: 100%;*/height: 800px; letter-spacing:normal !important;text-transform:none !important;text-shadow:none !important;box-shadow:none !important;border-radius:0 !important;padding: 0 15px 0 15px; margin:0; width:auto;}\
34 34 .noads_content textarea{height: 92%; border-radius: 3px; font:13px/normal "Courier New";cursor:auto;box-sizing:border-box;position:relative;border:1px solid;background:none;text-shadow:1px 1px 1px #666;color:#007;outline:none !important;width:100%;overflow:hidden;text-align:left;z-index:1000001 !important;border-color:#ccc #aaa #aaa #ccc;margin:0;padding:0 10px;}\
35 35 .noads_site_textarea{height: 29% !important;}\
36 36 .noads_content .inline .right{text-transform:none !important;text-shadow:none !important;box-shadow:none !important;border-radius:0 !important;position:relative;float:right;margin-right:22px;}\
@@ -42,9 +42,10 @@ var optionsCSS = '.noads_overlay{visibility:visible;background-color:#e3e5e7;dir
42 42 .noads_custom_url{font-size:10px;width:400px;margin:2px;}\
43 43 .noads_usercss_area{height:200px;width:100%;}\
44 44 .noads_allrules{margin:8px 0 2px 5px;}\
45   -.noads_content input[type="range"] {height: 100%;width: 50px;float:right;margin-top:20px;}\
  45 +.noads_content input[type="range"] {min-height:560px;height:100%;width:50px;float:right;margin-top:20px;}\
46 46 #noads_autoupdate_label {float:right;text-align: right;padding-bottom: 6px; height: 83%; width: 24%;}\
47   -.noads_subscriptions_block{height: 91%; overflow: auto; width: 75%;}\
  47 +/*.noads_content fieldset {border:none}*/\
  48 +.noads_subscriptions_block{/*height: 91%;*/height: 730px; margin: 0; overflow: auto; width: 75%;}\
48 49 .noads_input_help{font: bold 13px sans-serif;}\
49 50 .noads_help{background-color:#fafbfc;border:none;box-sizing:border-box;color:#000;font-family:monospace;font-size:14px;height:auto;overflow:auto;white-space:pre-wrap;width:96%;margin:4px 0;padding:0 4px;}';
50 51
@@ -241,18 +242,45 @@ var options = {
241 242 },
242 243
243 244 setRawRulesSite: function (name, value, domain) {
244   - if (value.indexOf('##') === -1 || typeof domain === 'undefined') return;
245   - var rule, pos, tmp = getValue(name).split('\n');
  245 + if (typeof domain === 'undefined') return;
  246 + var isNotEmptyRules = (value.replace(/\s/g, '').length !== 0),
  247 + vpos = value.indexOf('##'),
  248 + tmp = getValue(name).split('\n');
  249 +
  250 + if (isNotEmptyRules) {
  251 + // check rule correctness
  252 + if (vpos === -1) {
  253 + try {
  254 + // if we have `selectors` format
  255 + document.querySelectorAll(value);
  256 + value = domain + '##' + value;
  257 + } catch (bug) {
  258 + window.alert(lng.pInvalidSelector);
  259 + return;
  260 + }
  261 + } else {
  262 + try {
  263 + // if we have `domain.tld##selectors` format
  264 + var vsel = value.slice(vpos+2, value.length);
  265 + document.querySelectorAll(vsel);
  266 + if (!(vsel.replace(/\s/g,'').length)) isNotEmptyRules = false;
  267 + } catch (bug) {
  268 + window.alert(lng.pInvalidSelector);
  269 + return;
  270 + }
  271 + }
  272 + }
246 273
247   - for (var i = tmp.length; i--; ) {
  274 + for (var rpos, rule, i = tmp.length; i--;) {
248 275 rule = tmp[i];
249   - pos = rule.indexOf('##');
250   - if (pos !== -1 && options.isCorrectDomain(domain, rule.slice(0, pos))) {
  276 + rpos = rule.indexOf('##');
  277 + if (rpos !== -1 && options.isCorrectDomain(domain, rule.slice(0, rpos))) {
251 278 tmp.splice(i, 1);
252   - tmp.unshift(value);
253 279 break;
254 280 }
255 281 }
  282 +
  283 + if (isNotEmptyRules) tmp.unshift(value);
256 284 setValue(name, tmp.join('\n'));
257 285 },
258 286
@@ -347,14 +375,10 @@ var options = {
347 375 ];
348 376
349 377 var skipScripts = [
350   - // data scripts? o_O
351   - '^data:',
352   - '^opera:',
353   - '^widget:',
  378 + '^data:','^opera:','^widget:',
354 379 // TODO:
355   - // If we add all the sites this list will be endless shall we stop maybe?
356   - // Propably should load from separate and(or) JSON file.
357   - '^http://cdn\\d*\\.', // content delivery networks >_<
  380 + // Load list from separate and(or) JSON file using resource loader (12+).
  381 + '^https?://cdn\\d*\\.', // content delivery networks >_<
358 382 '^https?://(?:apis|maps|plus)+\\.google\\.com',
359 383 '^https?://www\\.google\\.com/(?:uds|cse|jsapi|recaptcha|support|s2)+',
360 384 '^https?://(?:api|api-read)\\.facebook\\.com',
@@ -368,7 +392,7 @@ var options = {
368 392 '^https?://[0-9a-z-\\.]+\\.com\\.com',
369 393 '^https?://[0-9a-z-\\.]+\\.s-msft\\.com',
370 394 '^https?://[0-9a-z-]*\\.cloudfront\\.net',
371   - '^https?://[0-9a-z-]*\\.disqus\\.com',
  395 + '^https?://[0-9a-z-\\.]*\\.disqus\\.com',
372 396 '^https?://[0-9a-z-]*\\.googleapis\\.com',
373 397 '^https?://[0-9a-z-]+\\.googlecode\\.com',
374 398 '^https?://[0-9a-z-]*\\.yahooapis\\.com',
@@ -382,13 +406,13 @@ var options = {
382 406 '^https?://[0-9a-z-]+\\.ltvimg\\.com',
383 407 '^https?://[0-9a-z-]+\\.olark\\.com',
384 408 '^https?://[0-9a-z-]+\\.wlxrs\\.com',
385   - '^https?://[0-9a-z\\.]*\\.?browserid\\.org',
386   - '^https?://[0-9a-z\\.]*zohostatic\\.com',
387   - '^https?://[0-9a-z\\.]+\\.akamai\\.net',
388   - '^https?://[0-9a-z\\.]+\\.cdnvideo\\.ru',
389   - '^https?://[0-9a-z\\.]+\\.edgecastcdn\\.net',
390   - '^https?://[0-9a-z\\.]+\\.longtailvideo\\.com',
391   - '^https?://[0-9a-z]+\\.fjcdn\\.com',
  409 + '^https?://[0-9a-z-\\.]*\\.?browserid\\.org',
  410 + '^https?://[0-9a-z-\\.]*zohostatic\\.com',
  411 + '^https?://[0-9a-z-]+\.akamai(?:hd)?\.net',
  412 + '^https?://[0-9a-z-\\.]+\\.cdnvideo\\.ru',
  413 + '^https?://[0-9a-z-\\.]+\\.edgecastcdn\\.net',
  414 + '^https?://[0-9a-z-\\.]+\\.longtailvideo\\.com',
  415 + '^https?://[0-9a-z-]+\\.fjcdn\\.com',
392 416 '^https?://a[0-9]+\\.e\\.fsimg\\.ru',
393 417 '^https?://i[0-9]+\\.services\\.social\\.microsoft\\.com',
394 418 '^https?://[0-9a-z\\.]*zohostatic\\.com',
@@ -453,7 +477,7 @@ var options = {
453 477 '^https?://www\\.paypalobjects\\.com',
454 478 '^https?://www\\.redditstatic\\.com',
455 479 '^https?://yandex\\.st',
456   - '^https?://94\\.198\\.241\\.153', // letitbit
  480 + '^https?://94\\.198\\.241\\.1(?:41|42|43|44|45|46|47|48|49|50|51|52|53)', // letitbit
457 481 // TODO:
458 482 // See comment before. That idea ends here.
459 483 '[a-z0-9]+\\.jq\\.(?:full|min|pack)+\\.js',
@@ -601,7 +625,7 @@ var options = {
601 625 delElement(overlay);
602 626 } else {
603 627 delete options.stop;
604   - self.close();
  628 + window.close();
605 629 }
606 630 };
607 631 this.stop = overlay.close;
@@ -641,11 +665,7 @@ var options = {
641 665 area.clear = function (num) {
642 666
643 667 this.innerHTML = '';
644   - /*
645   - while (this.firstChild) {
646   - this.removeChild(this.firstChild);
647   - }
648   - */
  668 + //while (this.firstChild) this.removeChild(this.firstChild);
649 669
650 670 if (arguments.length) {
651 671 for (var i = 0, li = document.querySelectorAll('#noads_menu li'), l = li.length; i < l; i++) {
@@ -725,8 +745,8 @@ var options = {
725 745 p.appendChild(document.createTextNode(hTxt));
726 746 this.appendChild(p);
727 747
728   - //textarea.rows = global ? '34' : '10';
729   - textarea.rows = '100';
  748 + textarea.rows = global ? '40' : '14';
  749 + //textarea.rows = '100';
730 750 textarea.cols = '100';
731 751 textarea.value = options.getRawRules(sName, domain, global);
732 752 textarea.id = sID;
@@ -927,7 +947,7 @@ var options = {
927 947 this.appendChild(p);
928 948 var textarea = document.createElement('textarea');
929 949 textarea.id = 'noads_jsblocks_textarea';
930   - textarea.rows = '100';
  950 + textarea.rows = '12';
931 951 textarea.cols = '100';
932 952 textarea.className = 'noads_site_textarea';
933 953 textarea.spellcheck = false;
@@ -943,7 +963,7 @@ var options = {
943 963 var textarea = document.getElementById('noads_jsblocks_textarea');
944 964 var val = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd).replace(/^\s+|\r|\s+$/g, '');
945 965 if (val) {
946   - val = val.replace(/[*+?^=!${}()|[\]\\]|\.(?!\w)/g, '\\$&').replace(/\n+/g, '|');
  966 + val = val.replace(/[*+?^=!${}()\.|[\]\\]|\.(?!\w)/g, '\\$&').replace(/http:/gi,'https?:').replace(/\n+/g, '|');
947 967 var whitelist = getValue('noads_scriptlist_white');
948 968 setValue('noads_scriptlist_white', '@@==' + val + (whitelist ? '\n' + whitelist : ''));
949 969 alert(lng.pBlockedAdded + ' ' + val);
@@ -1037,7 +1057,7 @@ var options = {
1037 1057 block.className = 'noads_subscriptions_block';
1038 1058
1039 1059 this.createCheckboxButton.call(block, 'EasyList', 'https://easylist-downloads.adblockplus.org/easylist.txt');
1040   - this.createCheckboxButton.call(block, 'EasyList and EasyPrivacy combination', 'https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt');
  1060 + this.createCheckboxButton.call(block, 'EasyPrivacy/EasyList combination', 'https://easylist-downloads.adblockplus.org/easyprivacy+easylist.txt');
1041 1061 this.createCheckboxButton.call(block, 'RuAdList/EasyList russian', 'https://easylist-downloads.adblockplus.org/ruadlist+easylist.txt');
1042 1062 this.createCheckboxButton.call(block, 'EasyList german', 'https://easylist-downloads.adblockplus.org/easylistgermany.txt');
1043 1063 this.createCheckboxButton.call(block, 'EasyList bulgarian', 'http://stanev.org/abp/adblock_bg.txt');
8 includes/noads.js
@@ -79,8 +79,8 @@ function onPopupMessageHandler(e) {
79 79 case 'show_preferences':
80 80 options.showPreferences(domain);
81 81 break;
82   - case 'ask_menu_status':
83   - e.source.postMessage(encodeMessage({type: 'menu_status_enable'}));
  82 + case 'ask_status':
  83 + e.source.postMessage(encodeMessage({type: 'status_enabled'}));
84 84 break;
85 85 }
86 86 }
@@ -250,9 +250,11 @@ window.addEventListener('DOMContentLoaded', function () {
250 250 addStyle(quickButtonCSS, 'qbCSS');
251 251 window.addEventListener('mousemove', showQuickButton, false);
252 252 }
  253 +
  254 + sendMessage({type: 'status_enabled'});
253 255 }
254 256 }
255   -}, false);
  257 +}, true);
256 258
257 259 // Main body
258 260 (function () {
56 scripts/noads-background.js
... ... @@ -1,8 +1,9 @@
1   -var button, notification_text = '', debug = false, lng = {}, menu_resized = false, actual_font = 0;
  1 +var button, notification_text = '', debug = false, lng = {}, menu_resized = false, actual_font = 0;
2 2
3 3 window.addEventListener('load', function () {
4   - debug = options.checkEnabled('noads_debug_enabled_state');
5   - lng = new TRANSLATION();
  4 + var debug = options.checkEnabled('noads_debug_enabled_state'),
  5 + lng = new TRANSLATION (),
  6 + v12 = (typeof opera.extension.tabGroups !== 'undefined');
6 7
7 8 if (options.checkEnabled('noads_tb_enabled_state')) {
8 9 button = opera.contexts.toolbar.createItem({
@@ -14,7 +15,7 @@ window.addEventListener('load', function () {
14 15 width: lng.baseMenuWidth || 180,
15 16 height: lng.baseMenuHeight || 155
16 17 },
17   - badge : {
  18 + badge: {
18 19 display: 'none',
19 20 textContent: '0',
20 21 color: 'white',
@@ -23,26 +24,43 @@ window.addEventListener('load', function () {
23 24 });
24 25 opera.contexts.toolbar.addItem(button);
25 26 } else {
26   - button = { disabled: true };
  27 + button = {
  28 + disabled: true
  29 + };
27 30 }
28 31
29   - function enableButton () {
30   - button.disabled = !opera.extension.tabs.getFocused();
  32 + function toggleButton (e) {
  33 + var atab = opera.extension.tabs.getFocused();
  34 + button.disabled = v12 ? !atab.port : !atab;
  35 + }
  36 +
  37 + function setButtonState (port, state) {
  38 + if (v12) {
  39 + // in case source tab is active
  40 + if (port === opera.extension.tabs.getFocused().port) {
  41 + button.disabled = !state;
  42 + }
  43 + }
31 44 }
32 45
33 46 function onConnectHandler (e) {
34   - var tab = opera.extension.tabs.getFocused();
35   - if (!tab) return;
  47 + var atab = opera.extension.tabs.getFocused();
  48 + if (!atab || !e) return;
36 49 // if we got a message fom the menu
37   - if (e && e.origin && ~e.origin.indexOf('menu.html') && ~e.origin.indexOf('widget://')) {
38   - tab.postMessage(encodeMessage({ type: 'noads_bg_port' }), [e.source]);
  50 + if (e.origin && ~e.origin.indexOf('menu.html') && ~e.origin.indexOf('widget://')) {
  51 + atab.postMessage(encodeMessage({ type: 'noads_bg_port' }), [e.source]);
39 52 } else {
40 53 // if we got a message fom a page
41 54 if (notification_text !== '') {
42   - tab.postMessage(encodeMessage({ type: 'noadsadvanced_autoupdate', text: notification_text}));
  55 + atab.postMessage(encodeMessage({
  56 + type: 'noadsadvanced_autoupdate',
  57 + text: notification_text
  58 + }));
43 59 notification_text = '';
44 60 }
45   - enableButton();
  61 +
  62 + // button will be disabled for new tabs
  63 + setButtonState(e.source, false);
46 64 }
47 65 }
48 66
@@ -54,6 +72,9 @@ window.addEventListener('load', function () {
54 72 // button.badge.textContent = message.blocked || '0';
55 73 // button.badge.color = "white";
56 74 // break;
  75 + case 'status_enabled':
  76 + setButtonState(e.source, true);
  77 + break;
57 78 case 'get_filters':
58 79 if (!e.source) return;
59 80
@@ -67,8 +88,7 @@ window.addEventListener('load', function () {
67 88 return;
68 89 }
69 90
70   - var message_rules = 0, message_success = [], message_error = [], message_fileerror = [],
71   - importerCallback = function (rulesN) {
  91 + var message_rules = 0, message_success = [], message_error = [], message_fileerror = [], importerCallback = function (rulesN) {
72 92 if (rulesN) {
73 93 message_success.push(message.url[subsc]);
74 94 message_rules = rulesN;
@@ -145,7 +165,7 @@ window.addEventListener('load', function () {
145 165 if (options.checkEnabled('noads_autoupdate_state')) {
146 166 var next_update = Number(getValue('noads_last_update')) + Number(getValue('noads_autoupdate_interval'));
147 167 if (next_update < Date.now()) {
148   - var url = options.getSubscriptions(), allRules = options.checkEnabled('noads_allrules_state'), importerCallback = function(rulesN) {
  168 + var url = options.getSubscriptions(), allRules = options.checkEnabled('noads_allrules_state'), importerCallback = function (rulesN) {
149 169 notification_text = lng.pAutoUpdateComplete || 'NoAds Advanced autoupdated';
150 170 };
151 171 for (var subsc = 0, l = url.length; subsc < l; subsc++) {
@@ -164,7 +184,7 @@ window.addEventListener('load', function () {
164 184
165 185 // Enable the button when a tab is ready.
166 186 opera.extension.onconnect = onConnectHandler;
167   - opera.extension.tabs.onfocus = enableButton;
168   - opera.extension.tabs.onblur = enableButton;
  187 + opera.extension.tabs.onfocus = toggleButton;
  188 + //opera.extension.tabs.onblur = toggleButton;
169 189 opera.extension.onmessage = onMessageHandler;
170 190 }, false);
6 scripts/noads-menu.js
@@ -7,7 +7,7 @@ html.setAttribute('xml:lang', window.navigator.language);
7 7 function onMessageHandler (e) {
8 8 if (!e || !e.data) return;
9 9 // if we want to interact with the menu from injected script
10   - if (decodeMessage(e.data).type === 'menu_status_enable') {
  10 + if (decodeMessage(e.data).type === 'status_enabled') {
11 11 if (document && document.body) {
12 12 document.body.style.color = 'black';
13 13 }
@@ -21,7 +21,7 @@ function sendCommand (message) {
21 21 theport.postMessage(encodeMessage(message));
22 22 } catch(e) {}
23 23 }
24   - self.close();
  24 + window.close();
25 25 }
26 26
27 27
@@ -72,7 +72,7 @@ window.addEventListener('DOMContentLoaded', function () {
72 72
73 73 if (theport) {
74 74 try {
75   - theport.postMessage(encodeMessage({type: 'ask_menu_status'}));
  75 + theport.postMessage(encodeMessage({type: 'ask_status'}));
76 76 } catch(e) {}
77 77 }
78 78
2  styles/noads-menu.css
@@ -4,7 +4,7 @@ body {
4 4 margin: 0;
5 5 padding-left: 0;
6 6 padding-right: 0;
7   - background-color: white;
  7 + background-color: #f4f4f5;
8 8 color: black;
9 9 font-family: Tahoma, Sans-serif;
10 10 font-size: 12px !important;

No commit comments for this range

Something went wrong with that request. Please try again.