Dinzer Lite

Protect Your Website!

  1. // ==UserScript==
  2. // @name Dinzer Lite
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Protect Your Website!
  6. // @author ChessDevx
  7. // @match *://*/*
  8. // @grant GM_addStyle
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. const settings = {
  16. adBlocker: GM_getValue('adBlocker', true),
  17. popupBlocker: GM_getValue('popupBlocker', true),
  18. darkMode: GM_getValue('darkMode', false),
  19. speedBoost: GM_getValue('speedBoost', true)
  20. };
  21. function saveSettings() {
  22. for (const key in settings) {
  23. GM_setValue(key, settings[key]);
  24. }
  25. }
  26. function blockAds() {
  27. if (!settings.adBlocker) return;
  28. const adSelectors = [
  29. 'div[id*="banner"]',
  30. 'div[id*="ad-"]',
  31. 'div[class*="ad-"]',
  32. 'div[class*="ads"]',
  33. 'div[id*="ads"]',
  34. 'iframe[src*="doubleclick"]',
  35. 'iframe[src*="ads"]',
  36. '.adsbygoogle',
  37. 'div[class*="sponsor"]',
  38. 'div[id*="sponsor"]',
  39. 'div[class*="promoted"]',
  40. 'div[id*="promoted"]',
  41. 'div[class*="advertisement"]',
  42. 'div[id*="advertisement"]',
  43. 'iframe[src*="adservice"]',
  44. 'iframe[src*="googlesyndication"]',
  45. 'iframe[src*="popads"]',
  46. 'div[class*="popup-ad"]',
  47. 'div[class*="ad-container"]',
  48. 'div[class*="ad-slot"]',
  49. 'div[class*="ad-placeholder"]',
  50. 'div[id*="ad-container"]',
  51. 'div[id*="ad-slot"]',
  52. 'div[id*="ad-placeholder"]',
  53. 'div[class*="sponsored-content"]',
  54. 'div[id*="sponsored-content"]',
  55. 'div[class*="google-ad"]',
  56. 'div[id*="google-ad"]',
  57. 'iframe[src*="adtech"]',
  58. 'iframe[src*="adserver"]',
  59. 'div[class*="video-ad"]',
  60. 'div[id*="video-ad"]',
  61. 'div[class*="overlay-ad"]',
  62. 'div[id*="overlay-ad"]'
  63. ];
  64. function hideAds() {
  65. adSelectors.forEach(selector => {
  66. const elements = document.querySelectorAll(selector);
  67. elements.forEach(el => {
  68. el.style.display = 'none';
  69. });
  70. });
  71. }
  72. hideAds();
  73. const observer = new MutationObserver(hideAds);
  74. observer.observe(document.body, { childList: true, subtree: true });
  75. }
  76. function blockPopups() {
  77. if (!settings.popupBlocker) return;
  78. const originalOpen = window.open;
  79. window.open = function() {
  80. if (arguments[1] && arguments[1].includes('_blank')) {
  81. arguments[1] = '_self';
  82. }
  83. return originalOpen.apply(this, arguments);
  84. };
  85. function processLinks() {
  86. document.querySelectorAll('a[target="_blank"]').forEach(link => {
  87. link.setAttribute('target', '_self');
  88. });
  89. }
  90. processLinks();
  91. const observer = new MutationObserver(processLinks);
  92. observer.observe(document.body, { childList: true, subtree: true });
  93. }
  94. function applyDarkMode() {
  95. if (!settings.darkMode) {
  96. if (document.getElementById('webProtectorDarkMode')) {
  97. document.getElementById('webProtectorDarkMode').disabled = true;
  98. }
  99. return;
  100. }
  101. const darkModeCSS = `
  102. html {
  103. filter: invert(90%) hue-rotate(180deg) !important;
  104. background: #fefefe !important;
  105. }
  106. img, video, canvas, picture, svg, [style*="background-image"] {
  107. filter: invert(100%) hue-rotate(180deg) !important;
  108. }
  109. [style*="background-color"], [style*="background:#"], [style*="background: #"] {
  110. filter: invert(100%) hue-rotate(180deg) !important;
  111. }
  112. :root {
  113. --darkreader-neutral-background: #d4cec9 !important;
  114. --darkreader-neutral-text: #121010 !important;
  115. --darkreader-selection-background: #88d8f8 !important;
  116. --darkreader-selection-text: #000 !important;
  117. }
  118. ::selection {
  119. background-color: var(--darkreader-selection-background) !important;
  120. color: var(--darkreader-selection-text) !important;
  121. }
  122. input, textarea, select, button {
  123. background-color: #333 !important;
  124. color: #eee !important;
  125. border-color: #666 !important;
  126. filter: invert(100%) hue-rotate(180deg) !important;
  127. }
  128. iframe {
  129. filter: invert(100%) hue-rotate(180deg) brightness(0.8) !important;
  130. }
  131. * {
  132. text-shadow: none !important;
  133. box-shadow: none !important;
  134. }
  135. pre, code, pre *, code * {
  136. filter: invert(100%) hue-rotate(180deg) !important;
  137. background-color: #222 !important;
  138. color: #eee !important;
  139. }
  140. #webProtectorUI, #webProtectorUI * {
  141. filter: invert(100%) hue-rotate(180deg) !important;
  142. }
  143. `;
  144. if (!document.getElementById('webProtectorDarkMode')) {
  145. const style = document.createElement('style');
  146. style.id = 'webProtectorDarkMode';
  147. style.textContent = darkModeCSS;
  148. document.head.appendChild(style);
  149. } else {
  150. document.getElementById('webProtectorDarkMode').disabled = false;
  151. }
  152. }
  153. function applySpeedBoost() {
  154. if (!settings.speedBoost) return;
  155. document.querySelectorAll('img').forEach(img => {
  156. if (img.loading === 'lazy' && isElementInViewport(img)) {
  157. img.loading = 'eager';
  158. }
  159. if (img.getAttribute('data-src') && isElementInViewport(img)) {
  160. img.src = img.getAttribute('data-src');
  161. }
  162. });
  163. document.querySelectorAll('iframe:not([src*="youtube"]):not([src*="vimeo"])').forEach(iframe => {
  164. if (!isElementInViewport(iframe)) {
  165. iframe.setAttribute('data-src', iframe.src);
  166. iframe.removeAttribute('src');
  167. }
  168. });
  169. // Add preconnect for common domains
  170. const commonDomains = ['www.google-analytics.com', 'fonts.googleapis.com', 'fonts.gstatic.com'];
  171. commonDomains.forEach(domain => {
  172. if (document.querySelector(`link[href*="${domain}"]`)) {
  173. const link = document.createElement('link');
  174. link.rel = 'preconnect';
  175. link.href = `https://${domain}`;
  176. document.head.appendChild(link);
  177. }
  178. });
  179. }
  180. function isElementInViewport(el) {
  181. const rect = el.getBoundingClientRect();
  182. return (
  183. rect.top >= 0 &&
  184. rect.left >= 0 &&
  185. rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
  186. rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  187. );
  188. }
  189. function createUI() {
  190. const container = document.createElement('div');
  191. container.id = 'webProtectorUI';
  192. GM_addStyle(`
  193. #webProtectorUI {
  194. position: fixed;
  195. left: 20px;
  196. bottom: 20px;
  197. background: rgba(40, 44, 52, 0.9);
  198. color: white;
  199. padding: 10px;
  200. border-radius: 8px;
  201. font-family: Arial, sans-serif;
  202. z-index: 9999999;
  203. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  204. width: 200px;
  205. transition: all 0.3s ease;
  206. font-size: 14px;
  207. }
  208. #webProtectorUI.collapsed {
  209. width: auto;
  210. height: auto;
  211. }
  212. #webProtectorUI .header {
  213. display: flex;
  214. justify-content: space-between;
  215. align-items: center;
  216. margin-bottom: 10px;
  217. cursor: move;
  218. }
  219. #webProtectorUI .toggle-btn {
  220. cursor: pointer;
  221. user-select: none;
  222. }
  223. #webProtectorUI .options {
  224. display: flex;
  225. flex-direction: column;
  226. gap: 8px;
  227. }
  228. #webProtectorUI .option {
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. }
  233. #webProtectorUI .switch {
  234. position: relative;
  235. display: inline-block;
  236. width: 40px;
  237. height: 20px;
  238. }
  239. #webProtectorUI .switch input {
  240. opacity: 0;
  241. width: 0;
  242. height: 0;
  243. }
  244. #webProtectorUI .slider {
  245. position: absolute;
  246. cursor: pointer;
  247. top: 0;
  248. left: 0;
  249. right: 0;
  250. bottom: 0;
  251. background-color: #ccc;
  252. transition: .3s;
  253. border-radius: 20px;
  254. }
  255. #webProtectorUI .slider:before {
  256. position: absolute;
  257. content: "";
  258. height: 16px;
  259. width: 16px;
  260. left: 2px;
  261. bottom: 2px;
  262. background-color: white;
  263. transition: .3s;
  264. border-radius: 50%;
  265. }
  266. #webProtectorUI input:checked + .slider {
  267. background-color: #4cd964;
  268. }
  269. #webProtectorUI input:checked + .slider:before {
  270. transform: translateX(20px);
  271. }
  272. `);
  273. container.innerHTML = `
  274. <div class="header">
  275. <span>Web Protector</span>
  276. <span class="toggle-btn">➖</span>
  277. </div>
  278. <div class="options">
  279. <div class="option">
  280. <span>Ad Blocker</span>
  281. <label class="switch">
  282. <input type="checkbox" id="adBlocker" ${settings.adBlocker ? 'checked' : ''}>
  283. <span class="slider"></span>
  284. </label>
  285. </div>
  286. <div class="option">
  287. <span>Popup Blocker</span>
  288. <label class="switch">
  289. <input type="checkbox" id="popupBlocker" ${settings.popupBlocker ? 'checked' : ''}>
  290. <span class="slider"></span>
  291. </label>
  292. </div>
  293. <div class="option">
  294. <span>Dark Mode</span>
  295. <label class="switch">
  296. <input type="checkbox" id="darkMode" ${settings.darkMode ? 'checked' : ''}>
  297. <span class="slider"></span>
  298. </label>
  299. </div>
  300. <div class="option">
  301. <span>Speed Boost</span>
  302. <label class="switch">
  303. <input type="checkbox" id="speedBoost" ${settings.speedBoost ? 'checked' : ''}>
  304. <span class="slider"></span>
  305. </label>
  306. </div>
  307. </div>
  308. `;
  309. document.body.appendChild(container);
  310. const toggleBtn = container.querySelector('.toggle-btn');
  311. const options = container.querySelector('.options');
  312. let isCollapsed = false;
  313. toggleBtn.addEventListener('click', () => {
  314. isCollapsed = !isCollapsed;
  315. if (isCollapsed) {
  316. options.style.display = 'none';
  317. toggleBtn.textContent = '➕';
  318. container.classList.add('collapsed');
  319. } else {
  320. options.style.display = 'flex';
  321. toggleBtn.textContent = '➖';
  322. container.classList.remove('collapsed');
  323. }
  324. });
  325. container.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
  326. checkbox.addEventListener('change', function() {
  327. settings[this.id] = this.checked;
  328. saveSettings();
  329. if (this.id === 'adBlocker') blockAds();
  330. if (this.id === 'popupBlocker') blockPopups();
  331. if (this.id === 'darkMode') applyDarkMode();
  332. if (this.id === 'speedBoost') applySpeedBoost();
  333. });
  334. });
  335. makeElementDraggable(container, container.querySelector('.header'));
  336. }
  337. function makeElementDraggable(element, handle) {
  338. let isDragging = false;
  339. let offsetX, offsetY;
  340. handle.addEventListener('mousedown', function(e) {
  341. isDragging = true;
  342. offsetX = e.clientX - element.getBoundingClientRect().left;
  343. offsetY = e.clientY - element.getBoundingClientRect().top;
  344. e.preventDefault();
  345. });
  346. document.addEventListener('mousemove', function(e) {
  347. if (!isDragging) return;
  348. const x = e.clientX - offsetX;
  349. const y = e.clientY - offsetY;
  350. const maxX = window.innerWidth - element.offsetWidth;
  351. const maxY = window.innerHeight - element.offsetHeight;
  352. element.style.left = Math.max(0, Math.min(x, maxX)) + 'px';
  353. element.style.top = Math.max(0, Math.min(y, maxY)) + 'px';
  354. element.style.bottom = 'auto';
  355. });
  356. document.addEventListener('mouseup', function() {
  357. isDragging = false;
  358. });
  359. }
  360. function initialize() {
  361. setTimeout(() => {
  362. blockAds();
  363. blockPopups();
  364. applyDarkMode();
  365. applySpeedBoost();
  366. createUI();
  367. }, 100);
  368. }
  369. if (document.readyState === 'loading') {
  370. document.addEventListener('DOMContentLoaded', initialize);
  371. } else {
  372. initialize();
  373. }
  374. })();