· 9 years ago · Oct 07, 2016, 08:48 PM
1Hey, I'm working on a proxy & auto login based Chrome extension. I want two things from extensions,
2
31. First user login to my WordPress website and then cookies should be set on his chrome browser if he removes my extension or logs out from my WordPress site then my third part account automatically logout.
4
51: User can access my paid account without password like mail.com. I'll list account logo on my website, and when they click on the logo, a separate tab should be open like this **xyz.com/FB?=5555**. When they click on another company account every part of URL should be same except **FB** replace with account name Which I give like xyz.com/**gmail**?=5555
6
72: Account must be automatically log in from my assigned IP only which is possible with findproxyforurl function.
8
9Here is they code of my competitors and I understand most of it. But I don't know How I pull data from cookies. Maybe he has created a cookies or username+password file on his server to put data. As I can see, he allows his extension to send a response from his website. He has two extensions if you disable anyone extension then account log out automatically.
10
11Extension 1
12
13Manifile file
14
15<code>
16
17 {
18 "update_url": "clients2.google.com/service/update2/crx",
19 "manifest_version": 2,
20 "name": "SGB",
21 "description": "All SGB members must install this extension. Please do NOT remove this extension, until you unsubscribe. Thanks",
22 "version": "1.3.4",
23 "homepage_url": "abc.com/",
24 "minimum_chrome_version": "26.0",
25 "icons": {
26 "16": "icon16.png",
27 "48": "icon48.png",
28 "128": "icon128.png"
29 },
30 "browser_action": {
31 "default_icon": {
32 "19": "icon19.png",
33 "38": "icon38.png"
34 },
35 "default_title": "SGB Extension",
36 "default_popup": "popup.html"
37 },
38 "content_scripts": [
39 {
40 "matches": [
41 "*://*.fb.com/*",
42 "*://*.gmail.com/*"
43 ],
44 "js": [
45 "cs.js"
46 ],
47 "run_at": "document_end",
48 "all_frames": true
49 }
50 ],
51 "background": {
52 "scripts": [
53 "background.js"
54 ]
55 },
56 "permissions": [
57 "webRequest",
58 "webRequestBlocking",
59 "tabs",
60 "proxy",
61 "cookies",
62 "management",
63 "http://*/*",
64 "https://*/*"
65 ],
66 "externally_connectable": {
67 "matches": [
68 "*://*.example.com/*"
69
70 ]
71 }
72}
73
74
75Background js
76
77<code>
78
79chrome.webRequest.onBeforeRequest.addListener(function(details) {
80 return {
81 cancel: true
82 };
83}, {
84 urls:
85 "*.Facebook.com/account/logout*",
86 ]
87}, ["blocking"]);
88
89function isBoolean(value) {
90 return (value) === 'true';
91}
92
93
94 Note: I guess he set cookies from this code on browser
95
96<code>
97
98chrome.runtime.onMessageExternal.addListener(
99 function(message, sender, sendResponse) {
100 if ((sender.url)
101 .indexOf("example.com") != -1 || (sender.url)
102 chrome.cookies.set({
103 url: message.url,
104 name: message.name,
105 value: message.value,
106 domain: message.domain,
107 path: message.path,
108 secure: message.secure,
109 httpOnly: isBoolean(message.httpOnly),
110 expirationDate: Number(message.expirationDate)
111 });
112 }
113);
114
115He calls a **CS dot JS** in Manifest file and here is its coding.
116
117<code>
118
119document.getElementById('text-input-content')
120 .innerHTML = '<b>Paste URL option is not available. Please choose Upload option</b>';
121
122
123Following is Extension 2 File.
124
125<code>
126
127Manifest
128
129{
130 "update_url": "clients2.google.com/service/update2/crx",
131 "manifest_version": 2,
132 "name": "SGBSecondary",
133 "description": "All SGB members must install this second extension. Please do NOT disable this extension, until you unsubscribe. Thanks",
134 "version": "1.3.2",
135 "homepage_url": "abccom/",
136 "minimum_chrome_version": "26.0",
137 "icons": {
138 "16": "icon16.png",
139 "48": "icon48.png",
140 "128": "icon128.png"
141 },
142 "externally_connectable": {
143 "matches": [
144 "*://*.example.com/*",
145
146 ]
147 },
148 "browser_action": {
149 "default_icon": {
150 "19": "icon19.png",
151 "38": "icon38.png"
152 },
153 "default_title": "SGB Secondary Extension",
154 "default_popup": "popup.html"
155 },
156 "permissions": [
157 "webRequest",
158 "webRequestBlocking",
159 "tabs",
160 "proxy",
161 "cookies",
162 "management",
163 "http://*/*",
164 "https://*/*"
165 ],
166 "background": {
167 "scripts": [
168 "background2.js"
169 ]
170 }
171}
172
173
174This 2nd Extension background file coding below.
175
176<code>
177
178var config = {
179 mode: "pac_script",
180 pacScript: {
181 data: "function FindProxyForURL(url, host) {\n" +
182 "if ((host).indexOf('fb.com') != -1)\n" +
183 "return 'PROXY xxx.xxx.xxx.xxx:3128';\n" +
184 "else if ((host).indexOf(gmail.com') != -1 || (host).indexOf('twitter.com') != -1 || (host).indexOf('mail.com') != -1)\n" +
185 "return 'PROXY xxx.z.xx.xx:80';\n" +
186 "}"
187 }
188};
189
190chrome.proxy.settings.set({
191 value: config,
192 scope: 'regular'
193}, function() {});
194
195chrome.runtime.onMessageExternal.addListener(
196 function(message, sender, sendResponse) {
197 if ((sender.url)
198 .indexOf("example.com/") != -1 || (sender.url)
199 sendResponse({});
200 }
201 });
202chrome.management.onDisabled.addListener(function(info) {
203 if (info.name == "SGB") {
204 chrome.cookies.getAll({}, function(cookies) {
205 chrome.cookies.remove({
206 url: '://gmail.com',
207 name: "STOK"
208 });
209 });
210 alert("You have disabled spycompetitors.com extension. All accounts are logged out. Both extensions must be enabled to login");
211 }
212});
213
214
215I don't how & which function he use for fetch dat from server & auto log i.