From 09abd889e94197bc3c578bd015159e179d1ea4cf Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Fri, 10 Nov 2017 14:14:50 +0100 Subject: [PATCH] Add ID to <html> for selector priority --- Core/Notification/TweetNotification.cs | 2 +- Resources/Scripts/code.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/Notification/TweetNotification.cs b/Core/Notification/TweetNotification.cs index fbd191f8..b16405af 100644 --- a/Core/Notification/TweetNotification.cs +++ b/Core/Notification/TweetNotification.cs @@ -5,7 +5,7 @@ namespace TweetDuck.Core.Notification{ sealed class TweetNotification{ - private const string DefaultHeadLayout = @"<html class='os-windows txt-size--14' data-td-font='medium' data-td-theme='dark'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'><style type='text/css'>body{background:#222426}</style>"; + private const string DefaultHeadLayout = @"<html id='tduck' class='os-windows txt-size--14' data-td-font='medium' data-td-theme='dark'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'><style type='text/css'>body{background:#222426}</style>"; private static readonly string CustomCSS = ScriptLoader.LoadResource("styles/notification.css"); public static TweetNotification Example(string html, int characters){ diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 5ba71434..f62acd27 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -271,7 +271,7 @@ let themeName = TD.settings.getTheme(); let tags = [ - `<html class='os-windows ${themeName} ${(doc.getAttribute("class").match(/txt-\S+/) || [ "txt-size--14" ])[0]}' data-td-font='${fontSizeName}' data-td-theme='${themeName}'><head>` + "<html "+Array.prototype.map.call(document.documentElement.attributes, ele => `${ele.name}="${ele.value}"`).join(" ")+"><head>" ]; $(document.head).children("link[href*='css/font.']:first,link[href*='css/app-"+themeName+".']:first,meta[charset],meta[http-equiv]").each(function(){ @@ -309,7 +309,7 @@ })(); // - // Block: Fix OS name. + // Block: Fix OS name and add ID to the document for priority CSS selectors. // if (ensurePropertyExists(TD, "util", "getOSName")){ TD.util.getOSName = function(){ @@ -320,6 +320,8 @@ doc.classList.add("os-windows"); } + doc.id = "tduck"; + // // Block: Enable popup notifications. //