Tip: Safari 13.0.5 + Twitter old layout without account

nsgr

macrumors 6502
Original poster
May 22, 2017
317
114
Test:
Macbook Pro 15" Early 2011

High Sierra 10.13.6 (17G11023)

Safari 13.0.5 (13608.5.12)


Twitter New Layout - Safari 13.0.5 (13608.5.12)

Safari -> menu Develop -> User Agent -> Default (Automatically Chosen):

Code:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15

The "problem" Twitter New Layout is "Version/13.0.5 Safari/605.1.15".



Twitter Old Layout:

Safari -> menu Develop -> User Agent -> Other -> copy and paste code below -> button OK

Code:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)
or

Code:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X) AppleWebKit/419 (KHTML, like Gecko)
or

Code:
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko


Safari test current page/ current tab:

1 - Open Safari

2 - Safari -> menu Preferences -> Advanced -> Show Develop menu in menu bar

3 - Safari -> menu Safari -> Clear History -> Clear: all history -> button Clear History

4 - Safari -> menu Develop -> User Agent -> Other -> copy and paste code below -> button OK:

Code:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)
or

Code:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko)
or

Code:
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko

5 - Enter Macrumors Twitter and see Twitter old layout - current page / current tab:



6 - This procedure only works on the current page (tab).
If you open a new tab or "open link in a new tab", then the configuration of the Twitter old layout will be lost.


Make this setting permanent - all pages - all tabs:

1 - Open Safari

2 - Safari -> menu Safari -> Clear History -> Clear: all history -> button Clear History

3 - Close Safari

4 - Finder -> Applications -> Utilities -> Terminal -> copy and paste code below and press ENTER key.


Code:
defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)\""
or

Code:
defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X) AppleWebKit/419 (KHTML, like Gecko)\""
or

Code:
defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko\""

Delete/ Restore to Safari's default mode - User Agent: Default (Automatically Chosen):

1 - Open Safari

2 - Safari -> menu Safari -> Clear History -> Clear: all history -> button Clear History

3 - Close Safari

4 - Finder -> Applications -> Utilities -> Terminal -> copy and paste code below and press ENTER key.

Code:
defaults delete com.apple.Safari CustomUserAgent


References:

1 - How to get the old Twitter web interface back



2 - How to reverse the defaults write com.apple.Safari CustomUserAgent “\”My user agent string\“” command


3 - User Agent String.Com
 
Last edited:

nsgr

macrumors 6502
Original poster
May 22, 2017
317
114
Update 1:

I had a problem with Google search -> old layout -> top black bar.

I added Safari/605.1.15 and solved the problem.

I just removed Version/13.0.5 .

Now -> Twitter Old Layout + Google search New Layout


Safari test current page/ current tab:

1 - Safari -> menu Develop -> User Agent -> Other -> copy and paste code below -> button OK:

Code:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Safari/605.1.15


Make this setting permanent - all pages - all tabs:

1 - Finder -> Applications -> Utilities -> Terminal -> copy and paste code below and press ENTER key.

Code:
defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Safari/605.1.15\""


Delete/ Restore to Safari's default mode - User Agent: Default (Automatically Chosen):

1 - Finder -> Applications -> Utilities -> Terminal -> copy and paste code below and press ENTER key.

Code:
defaults delete com.apple.Safari CustomUserAgent
 

Attachments

nsgr

macrumors 6502
Original poster
May 22, 2017
317
114
So far I have not found a unique solution for Twitter, Google_dot_com and Youtube.

Youtube shows the Old Layout (no dark theme option) and the message that the web browser needs to be upgraded.

Chrome has the GoodTwitter extension by the developer Zusor.

Code:
/Users/YOUR_USER_Login/Library/Application\ Support/Google/Chrome/Default/Extensions/jbanhionoclikdjnjlcmefiofgjimgca/2.0_0/

symbol ~ equal shortcut Your_User_Login

cd = change directory in Terminal app

Code:
cd ~/Library/Application\ Support/Google/Chrome/Default/Extensions/jbanhionoclikdjnjlcmefiofgjimgca/2.0_0/

or


Finder -> menu Go -> Go to Folder ->
Code:
~/Library/Application Support/Google/Chrome/Default/Extensions/jbanhionoclikdjnjlcmefiofgjimgca/2.0_0/

Inside the directory above there is the background.js file.

Code:
"use strict";

const requestFilter = {
    urls: ["https://*.twitter.com/*"]
};

const extraInfoSpec = ['requestHeaders', 'blocking', 'extraHeaders'];
// Chrome will call your listener function in response to every
// HTTP request
const handler = function (details) {

    let headers = details.requestHeaders;
    let blockingResponse = {};
    const l = headers.length;
    for (let i = 0; i < l; ++i) {
        if (headers[i].name === 'User-Agent') {
            headers[i].value = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) Waterfox/56.2';
        } else if (headers[i].name === 'Cookie') {
            headers[i].value = headers[i].value.replace(/rweb_optin=.*?(; .*)?$/i, "rweb_optin=off$1");
        }
    }

    blockingResponse.requestHeaders = headers;
    return blockingResponse;
};

function removeCookie() {
    chrome.browsingData.remove({"origins": ["https://twitter.com"]}, {"cacheStorage": true, "cache": true});
    chrome.tabs.query({url: "*://*.twitter.com/*"}, function (result) {
        result.forEach(function (tab) {
            chrome.tabs.reload(tab.id)
        })
    });
}

chrome.webRequest.onBeforeSendHeaders.addListener(handler, requestFilter, extraInfoSpec);
chrome.runtime.onInstalled.addListener(removeCookie);

Basically, background.js looks at the URL "*.twitter.com/*" and uses the User Agent and change to Twitter old layout:

Code:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) Waterfox/56.2

It also reloads each Tab that will open with the User Agent above only for "*.twitter.com/*" .

It also has the option "rweb_optin = off or on" but on some sites it says that this option is no longer working.


Twitter web page inside Safari - script.js - about User Agent

Safari -> Twitter Macrumors page -> menu Develop -> Show Web Inspector -> tab Resources -> All Resources -> Extension Scripts -> script.js -- 7f28a ... fe6a

Code:
var matches = reOS.exec(navigator.userAgent);

var operatingSystem = (matches || [])[1] || "Unknown";

var operatingSystemVersion = (matches || [])[2] || "Unknown";

var reBW = /(MSIE|Trident|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari(?!.+Edge)|(?!AppleWebKit.+)Chrome(?!.+Edge)|(?!AppleWebKit.+Chrome.+Safari.+)Edge|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d\.apre]+)/;

matches = reBW.exec(navigator.userAgent);

var browserVersion = (matches || [])[2] || "Unknown";

var browserLanguage = navigator.language.match(/^[a-z]+/i)[0];

function dispatchPingDataInfo() {
    safari.extension.dispatchMessage("PING_DATA_INFO", {
                                     "version": browserVersion,
                                     "lang": browserLanguage,
                                     "os": operatingSystem,
                                     "os_version": operatingSystemVersion
                                     });
}

dispatchPingDataInfo()

Perhaps an Apple-certified developer can develop an Extension for Safari to solve this problem.

I was looking at the Safari documentation to see how to create a Safari Extension in Xcode.
I am not a developer and I also do not have an Apple developer certificate.

There is the option "Allow Unsigned Extensions" in Safari but a security breach could occur when browsing multiple sites.

Safari - menu Develop -> Allow Unsigned Extensions


References:

1 - GoodTwitter - Chrome web store


2 - GoodTwitter - Github

3 - Here’s how you can go back to the old Twitter layout - rweb_optin