forked from odensc/ttv-ublock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
chrome.webRequest.onBeforeSendHeaders.addListener( | ||
({ requestHeaders }) => { | ||
for (const header of requestHeaders) { | ||
if (header.name.toLowerCase() === "user-agent") | ||
header.value = "Googlebot"; | ||
} | ||
|
||
return { requestHeaders }; | ||
}, | ||
{ urls: ["*://*.ttvnw.net/*"] }, | ||
["blocking", "requestHeaders"] | ||
let userAgent = ""; | ||
|
||
chrome.storage.onChanged.addListener((changes) => { | ||
if (changes.userAgent) userAgent = changes.userAgent.newValue; | ||
}); | ||
|
||
chrome.storage.local.get( | ||
{ userAgent: "Mediapartners-Google" }, | ||
({ userAgent: storageUserAgent }) => { | ||
userAgent = storageUserAgent; | ||
|
||
chrome.webRequest.onBeforeSendHeaders.addListener( | ||
({ requestHeaders }) => { | ||
for (const header of requestHeaders) { | ||
if (header.name.toLowerCase() === "user-agent") | ||
header.value = userAgent; | ||
} | ||
|
||
return { requestHeaders }; | ||
}, | ||
{ urls: ["*://*.ttvnw.net/*"] }, | ||
["blocking", "requestHeaders"] | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>TTV Ad-block Options</title> | ||
</head> | ||
<body> | ||
<p> | ||
Find the latest user agent on | ||
<a | ||
href="https://raw.githubusercontent.com/odensc/ttv-ublock/extension/user-agent.txt" | ||
> | ||
GitHub | ||
</a> | ||
</p> | ||
|
||
<input class="userAgent" type="text" placeholder="User agent" /> | ||
<button class="save">Save</button> | ||
|
||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
chrome.storage.local.get( | ||
{ userAgent: "Mediapartners-Google" }, | ||
({ userAgent }) => (document.querySelector(".userAgent").value = userAgent) | ||
); | ||
|
||
document.querySelector(".save").addEventListener("click", () => { | ||
chrome.storage.local.set({ | ||
userAgent: document.querySelector(".userAgent").value, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Mediapartners-Google |