Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzpw authored Jan 2, 2024
1 parent caccf12 commit ddea9fd
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 46 deletions.
4 changes: 0 additions & 4 deletions youtube-ad-skipper-chrome/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ chrome.tabs.onUpdated.addListener((id, change, tab) => {
files: ["remove-ads.js"],
})
}
// chrome.scripting.executeScript({
// target: { tabId: tab.id },
// files: ["remove-ads.js"],
// });
});
19 changes: 14 additions & 5 deletions youtube-ad-skipper-chrome/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ adElements = [".ytd-companion-slot-renderer",
".ytd-primetime-promo-renderer",
".ytd-ad-slot-renderer",
];

unwantedElements = [
".ytd-promoted-video-renderer",
".ytd-brand-video-singleton-renderer",
Expand All @@ -25,7 +24,12 @@ unwantedElements = [
".ytd-rich-section-renderer",
".ytd-promoted-sparkles-web-renderer",
];

unwantedElementsSkipTagNames = [
"YP-YT-IRON-DROPDOWN",
"YTD-NOTIFICATION-TOPBAR-BUTTON-RENDERER",
"YT-BUTTON-SHAPE",
"IRON-MEDIA-QUERY",
];
function removeAdElements(){
let n = 0;
adElements.forEach((ad) => {
Expand Down Expand Up @@ -53,12 +57,17 @@ function removeAdElements(){
if (document.querySelectorAll(ad).length > 1){
document.querySelectorAll(ad).forEach((adSlot) => {
try{
document.querySelectorAll(ad).forEach((adSlot) => {
if (!adSlot.hidden){
if (!adSlot.hidden){
if (ad == ".ytd-popup-container"){
if (unwantedElementsSkipTagNames.indexOf(adSlot) != -1){
adSlot.hidden = true;
++n;
}
} else{
adSlot.hidden = true;
++n;
}
})
}
} catch (_ex) {
console.log(_ex, _ex.lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion youtube-ad-skipper-chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 3,
"version": "1.0",
"version": "1.1",
"author": "xyz",
"name": "Youtube Ad Skipper",
"icons": {
Expand Down
59 changes: 36 additions & 23 deletions youtube-ad-skipper-chrome/remove-ads.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
adElements = [".ytd-companion-slot-renderer",
".ytd-action-companion-ad-renderer",
".ytd-watch-next-secondary-results-renderer.sparkles-light-cta",
".ytd-unlimited-offer-module-renderer",
".ytp-ad-overlay-image", ".ytp-ad-text-overlay",
"div#root.style-scope.ytd-display-ad-renderer.yt-simple-endpoint",
"div#sparkles-container.style-scope.ytd-promoted-sparkles-web-renderer",
".ytd-display-ad-renderer",
".ytd-statement-banner-renderer",
".ytd-in-feed-ad-layout-renderer",
"div#player-ads.style-scope.ytd-watch-flexy",
"div#panels.style-scope.ytd-watch-flexy",
".ytd-banner-promo-renderer",
".ytd-video-masthead-ad-v3-renderer",
".ytd-primetime-promo-renderer",
".ytd-in-feed-ad-layout-renderer",
".ytd-ad-slot-renderer",
adElements = [
".ytd-companion-slot-renderer",
".ytd-action-companion-ad-renderer",
".ytd-watch-next-secondary-results-renderer.sparkles-light-cta",
".ytd-unlimited-offer-module-renderer",
".ytp-ad-overlay-image",
".ytp-ad-text-overlay",
"div#root.style-scope.ytd-display-ad-renderer.yt-simple-endpoint",
"div#sparkles-container.style-scope.ytd-promoted-sparkles-web-renderer",
".ytd-display-ad-renderer",
".ytd-statement-banner-renderer",
".ytd-in-feed-ad-layout-renderer",
"div#player-ads.style-scope.ytd-watch-flexy",
"div#panels.style-scope.ytd-watch-flexy",
".ytd-banner-promo-renderer",
".ytd-video-masthead-ad-v3-renderer",
".ytd-primetime-promo-renderer",
".ytd-in-feed-ad-layout-renderer",
".ytd-ad-slot-renderer",
];

unwantedElements = [
".ytd-promoted-video-renderer",
".ytd-brand-video-singleton-renderer",
".ytd-brand-video-shelf-renderer",
".ytd-popup-container",
".ytd-rich-section-renderer",
".ytd-promoted-sparkles-web-renderer",
]

];
unwantedElementsSkipTagNames = [
"YP-YT-IRON-DROPDOWN",
"YTD-NOTIFICATION-TOPBAR-BUTTON-RENDERER",
"YT-BUTTON-SHAPE",
"IRON-MEDIA-QUERY",
];
function removeRemainingAds(){
let n = 0;
adElements.forEach((ad) => {
Expand Down Expand Up @@ -54,16 +60,23 @@ function removeRemainingAds(){
try{
document.querySelectorAll(ad).forEach((adSlot) => {
if (!adSlot.hidden){
adSlot.hidden = true;
++n;
if (ad == ".ytd-popup-container"){
if (unwantedElementsSkipTagNames.indexOf(adSlot) != -1){
adSlot.hidden = true;
++n;
}
} else{
adSlot.hidden = true;
++n;
}
}
});
} catch (_ex){
console.log(_ex, _ex.lineNumber);
}
}
if (currentAd){
if (!currentAd.hidden){
if (!currentAd.hidden && ad != ".ytd-popup-container"){
currentAd.hidden = true;
++n;
}
Expand Down
3 changes: 0 additions & 3 deletions youtube-ad-skipper-firefox/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ browser.tabs.onUpdated.addListener((id, change, tab) => {
file: "remove-ads.js",
});
}
// browser.tabs.executeScript({
// file: "remove-ads.js",
// });
})
18 changes: 15 additions & 3 deletions youtube-ad-skipper-firefox/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ adElements = [".ytd-companion-slot-renderer",
".ytd-primetime-promo-renderer",
".ytd-ad-slot-renderer",
];

unwantedElements = [
".ytd-promoted-video-renderer",
".ytd-brand-video-singleton-renderer",
Expand All @@ -25,6 +24,12 @@ unwantedElements = [
".ytd-rich-section-renderer",
".ytd-promoted-sparkles-web-renderer",
];
unwantedElementsSkipTagNames = [
"YP-YT-IRON-DROPDOWN",
"YTD-NOTIFICATION-TOPBAR-BUTTON-RENDERER",
"YT-BUTTON-SHAPE",
"IRON-MEDIA-QUERY",
];

function removeAdElements(){
let n = 0;
Expand Down Expand Up @@ -55,8 +60,15 @@ function removeAdElements(){
try{
document.querySelectorAll(ad).forEach((adSlot) => {
if (!adSlot.hidden){
adSlot.hidden = true;
++n;
if (ad == ".ytd-popup-container"){
if (unwantedElementsSkipTagNames.indexOf(adSlot) != -1){
adSlot.hidden = true;
++n;
}
} else{
adSlot.hidden = true;
++n;
}
}
})
} catch (_ex) {
Expand Down
2 changes: 1 addition & 1 deletion youtube-ad-skipper-firefox/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"version": "1.0",
"version": "1.1",
"author": "xyz",
"name": "Youtube Ad Skipper",
"icons": {
Expand Down
24 changes: 18 additions & 6 deletions youtube-ad-skipper-firefox/remove-ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ adElements = [".ytd-companion-slot-renderer",
".ytd-in-feed-ad-layout-renderer",
".ytd-ad-slot-renderer",
];

unwantedElements = [
".ytd-promoted-video-renderer",
".ytd-brand-video-singleton-renderer",
".ytd-brand-video-shelf-renderer",
".ytd-popup-container",
".ytd-rich-section-renderer",
".ytd-promoted-sparkles-web-renderer",
]
];
unwantedElementsSkipTagNames = [
"YP-YT-IRON-DROPDOWN",
"YTD-NOTIFICATION-TOPBAR-BUTTON-RENDERER",
"YT-BUTTON-SHAPE",
"IRON-MEDIA-QUERY",
];

function removeRemainingAds(){
let n = 0;
Expand Down Expand Up @@ -54,21 +59,28 @@ function removeRemainingAds(){
try{
document.querySelectorAll(ad).forEach((adSlot) => {
if (!adSlot.hidden){
adSlot.hidden = true;
++n;
if (ad == ".ytd-popup-container"){
if (unwantedElementsSkipTagNames.indexOf(adSlot) != -1){
adSlot.hidden = true;
++n;
}
} else {
adSlot.hidden = true;
++n;
}
}
});
} catch (_ex){
console.log(_ex, _ex.lineNumber);
}
}
if (currentAd){
if (!currentAd.hidden){
if (!currentAd.hidden && ad != ".ytd-popup-container"){
currentAd.hidden = true;
++n;
}
}
})
});
let logMessage = `%cRemoved ${n} ads`;
n >= 1 ? console.log(logMessage, "color: #28a745") : console.log(logMessage, "color: #ffc107");
}
Expand Down

0 comments on commit ddea9fd

Please sign in to comment.