Browse Source

support multiple domains in sections

Andrew Dolgov 1 year ago
parent
commit
63509fd1e1
3 changed files with 12 additions and 6 deletions
  1. 9 2
      background.js
  2. 1 1
      manifest.json
  3. 2 3
      options.js

+ 9 - 2
background.js

@@ -21,12 +21,19 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
 			var line = lines[i];
 
 			if (line.indexOf("##") == 0) {
-				section = line.substr(2).trim();
+				section = line.substr(2).trim().split(",");
 				continue;
 			}
 
-			if (section == "" || section == "GLOBAL" || href.indexOf(section) != -1)
+			if (section[0] == "GLOBAL" || section.length == 0) {
 				tmp.push(line);
+			} else {
+				for (var j = 0; j < section.length; j++) {
+					if (href.indexOf(section[j].trim()) != -1) {
+						tmp.push(line);
+					}
+				}
+			}
 		}
 
 		sendResponse({user_css: tmp.join("\n")});

+ 1 - 1
manifest.json

@@ -8,7 +8,7 @@
 		"128": "icons/icon128.png" 
   },
   "name": "Bloat-free user stylesheets",
-  "version": "0.3",
+  "version": "0.4",
   "manifest_version": 2,
   "description": "Injects user stylesheets, without bloat.",
   "permissions": [ "http://*/*", "https://*/*", "storage" ],

+ 2 - 3
options.js

@@ -14,8 +14,8 @@ $(document).ready(function() {
 	editor.attr('placeholder',
 		"## GLOBAL\n" +
 		"{ global rules go here }\n" +
-		"## example.com\n"+
-		"{ rules for example.com}\n");
+		"## example.com,sample.com\n"+
+		"{ rules for example.com or sample.com }\n");
 
 	editor.attr('title', editor.attr('placeholder'));
 
@@ -33,4 +33,3 @@ $(document).ready(function() {
 
 
 });
-