From 2862754f63cb29186bf5ea016213f4a0fd03b84a Mon Sep 17 00:00:00 2001 From: hideheader Date: Wed, 18 Feb 2015 13:56:39 -0500 Subject: [PATCH] Support "breadcrumbs" new style links Adds support for 'new style' links that resemble the page URL. Requires stylesheet support to enable it. https://userstyles.org/styles/110560/breadcrumbs-new-style-links-stylish-for-chrome --- popup.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/popup.js b/popup.js index 51d5cea2..f7f3a872 100644 --- a/popup.js +++ b/popup.js @@ -19,7 +19,9 @@ chrome.tabs.getSelected(null, function(tab) { document.querySelector("#find-styles a").href = "https://userstyles.org/styles/browse/all/" + encodeURIComponent("file" === urlWillWork[1] ? "file:" : tab.url); // Write new style links - var writeStyleLinks = [] + var writeStyleLinks = [], + container = document.createElement('span'); + container.id = "match"; // For this URL var urlLink = writeStyleTemplate.cloneNode(true); @@ -38,17 +40,19 @@ chrome.tabs.getSelected(null, function(tab) { var domainLink = writeStyleTemplate.cloneNode(true); domainLink.href = "edit.html?domain=" + encodeURIComponent(domain); domainLink.appendChild(document.createTextNode(domain)); + domainLink.setAttribute("subdomain", domain.substring(0, domain.indexOf("."))); writeStyleLinks.push(domainLink); }); var writeStyle = document.querySelector("#write-style"); writeStyleLinks.forEach(function(link, index) { if (index > 0) { - writeStyle.appendChild(document.createTextNode(" ")); + container.appendChild(document.createTextNode(" ")); } link.addEventListener("click", openLinkInTabOrWindow, false); - writeStyle.appendChild(link); + container.appendChild(link); }); + writeStyle.appendChild(container); }); function showStyles(styles) {