google fixer

fix google annoying problems. currently it removes consent stuff from google and youtube, and you go directly to the web page instead of google feedback in google search.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name google fixer
// @description fix google annoying problems. currently it removes consent stuff from google and youtube, and you go directly to the web page instead of google feedback in google search.
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/*
// @match https://www.google.com/*
// @grant none
// @version 0.0.1.20190608185432
// ==/UserScript==
function delete_cookie(name, domain) {
  document.cookie = name + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=' + domain + ';';
}
const waitForIds = (...ids) => new Promise(resolve => {
  const delay = 500
  const f = () => {
    const elements = ids.map(id => document.getElementById(id))
    if (elements.every(element => element != null)) {
      resolve(elements)
    } else {
      setTimeout(f, delay)
    }
  }
  f()
})
const waitForTags = (...tags) => new Promise(resolve => {
  const delay = 500
  const f = () => {
    const elements = tags.flatMap(tag => document.getElementsByTagName(tag))
    if (elements.every(element => element != null)) {
      resolve(elements)
    } else {
      setTimeout(f, delay)
    }
  }
  f()
})
waitForIds('ticker').then(([ticker])=>{
  ticker.parentNode.removeChild(ticker);
})
waitForIds('consent-bump').then(([consentBump])=>{
  consentBump.parentNode.removeChild(consentBump);
})
waitForIds('lb').then(([lb])=>{
  lb.parentNode.removeChild(lb);
})
waitForIds('taw').then(([taw])=>{
  taw.parentNode.removeChild(taw);
})
waitForTags('ytd-popup-container').then(([ytd])=>{
  ytd.parentNode.removeChild(ytd);
})
waitForTags('a').then(([a])=>{
  console.log(a.length);
  for (var i = 0; i < a.length; i++) {
    console.log(a[i]);
    a[i].removeAttribute('onmousedown');
  }
})
delete_cookie('CONSENT', '.youtube.com');
delete_cookie('CONSENT', '.google.com');